mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
(enhance) introduce resolving strategy (configurable xml security); introduce API configuration
This commit is contained in:
parent
7a86f049ac
commit
35c0797898
67 changed files with 2441 additions and 845 deletions
|
|
@ -0,0 +1,95 @@
|
|||
package de.kosit.validationtool.config;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
import de.kosit.validationtool.impl.Scenario.Transformation;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.model.scenarios.CreateReportType;
|
||||
import de.kosit.validationtool.model.scenarios.ScenarioType;
|
||||
|
||||
/**
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class FallbackBuilder implements Builder<Scenario> {
|
||||
|
||||
private final ReportBuilder internal = new ReportBuilder().name("fallback");
|
||||
|
||||
@Override
|
||||
public Result<Scenario, String> build(final ContentRepository repository) {
|
||||
final ScenarioType object = createObject();
|
||||
final Result<Pair<CreateReportType, Transformation>, String> build = this.internal.build(repository);
|
||||
final Result<Scenario, String> result;
|
||||
if (build.isValid()) {
|
||||
object.setCreateReport(build.getObject().getLeft());
|
||||
final Scenario s = new Scenario(object);
|
||||
s.setFallback(true);
|
||||
s.setReportTransformation(build.getObject().getRight());
|
||||
result = new Result<>(s);
|
||||
} else {
|
||||
result = new Result<>(build.getErrors());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ScenarioType createObject() {
|
||||
final ScenarioType t = new ScenarioType();
|
||||
t.setName("Fallback-Scenario");
|
||||
t.setMatch("count(/)<0");
|
||||
// always reject
|
||||
t.setAcceptMatch("count(/)<0");
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifices a source for this report. This is either used to compile the report transformation or as documentation for
|
||||
* a precompiled tranformation.
|
||||
*
|
||||
* @param source the source
|
||||
* @return this
|
||||
*/
|
||||
public FallbackBuilder source(final String source) {
|
||||
this.internal.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifices a source for this report. This is either used to compile the report transformation or as documentation for
|
||||
* a precompiled tranformation.
|
||||
*
|
||||
* @param source the source
|
||||
* @return this
|
||||
*/
|
||||
public FallbackBuilder source(final URI source) {
|
||||
this.internal.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifices a source for this report. This is either used to compile the report transformation or as documentation for
|
||||
* a precompiled tranformation.
|
||||
*
|
||||
* @param source the source
|
||||
* @return this
|
||||
*/
|
||||
public FallbackBuilder source(final Path source) {
|
||||
this.internal.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the report source to a specific value.
|
||||
*
|
||||
* @param name the name
|
||||
* @return this
|
||||
*/
|
||||
public FallbackBuilder name(final String name) {
|
||||
this.internal.name(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue