-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mohamed Maza
committed
Jun 7, 2021
1 parent
8aeaf6c
commit 9b56a57
Showing
13 changed files
with
236 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/de/kosit/validationtool/impl/xvrl/BaseDetection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2017-2021 Koordinierungsstelle für IT-Standards (KoSIT) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.kosit.validationtool.impl.xvrl; | ||
|
||
import de.kosit.validationtool.model.reportInput.XMLSyntaxError; | ||
import de.kosit.validationtool.model.xvrl.Location; | ||
import de.kosit.validationtool.model.xvrl.XVRLDetection; | ||
import de.kosit.validationtool.model.xvrl.XVRLMessage; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static de.kosit.validationtool.api.XmlError.Severity.SEVERITY_FATAL_ERROR; | ||
|
||
public interface BaseDetection { | ||
|
||
List<XVRLMessage> getMessages(); | ||
|
||
List<Location> getLocations(); | ||
|
||
XVRLDetection.Severity getSeverity(); | ||
|
||
void setSeverity(XVRLDetection.Severity value); | ||
|
||
default List<String> getAllMessages() { | ||
return getMessages().stream().flatMap(message -> message.getMessageStrings().stream()).collect(Collectors.toList()); | ||
} | ||
|
||
default String getErrorMessage() { | ||
if (getMessages().isEmpty()) { | ||
return null; | ||
} | ||
return getMessages().get(0).getContent().stream().map(Object::toString).collect(Collectors.joining()); | ||
} | ||
|
||
default Location getErrorLocation() { | ||
if (getLocations().isEmpty()) { | ||
return null; | ||
} | ||
return getLocations().get(0); | ||
} | ||
|
||
default boolean hasErrors() { | ||
return getSeverity() == XVRLDetection.Severity.ERROR || getSeverity() == XVRLDetection.Severity.FATAL_ERROR; | ||
} | ||
|
||
default void addMessageString(String message) { | ||
XVRLMessage messageObject = new XVRLMessage(); | ||
messageObject.getContent().add(message); | ||
getMessages().add(messageObject); | ||
} | ||
|
||
default void addLocation(int lineNumber, int columnNumber, String xpath) { | ||
Location location = new Location(); | ||
location.setLine(BigInteger.valueOf(lineNumber)); | ||
location.setColumn(BigInteger.valueOf(columnNumber)); | ||
location.setXpath(xpath); | ||
getLocations().add(location); | ||
} | ||
|
||
default void addSeverityFromXmlError(XMLSyntaxError xmlSyntaxError) { | ||
if (xmlSyntaxError.getSeverity() == SEVERITY_FATAL_ERROR) { | ||
setSeverity(XVRLDetection.Severity.FATAL_ERROR); | ||
} else { | ||
setSeverity(XVRLDetection.Severity.ERROR); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/de/kosit/validationtool/impl/xvrl/BaseMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2017-2021 Koordinierungsstelle für IT-Standards (KoSIT) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.kosit.validationtool.impl.xvrl; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public interface BaseMessage { | ||
|
||
List<Object> getContent(); | ||
|
||
default List<String> getMessageStrings() { | ||
return getContent().stream().map(Object::toString).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/de/kosit/validationtool/impl/xvrl/BaseReportSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2017-2021 Koordinierungsstelle für IT-Standards (KoSIT) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package de.kosit.validationtool.impl.xvrl; | ||
|
||
import de.kosit.validationtool.model.xvrl.XVRLDetection; | ||
import de.kosit.validationtool.model.xvrl.XVRLReport; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public interface BaseReportSummary { | ||
|
||
List<XVRLReport> getReports(); | ||
|
||
default List<String> getAllErrors() { | ||
return getReports().stream().flatMap(xvrlReport -> xvrlReport.getAllErrors().stream()).collect(Collectors.toList()); | ||
} | ||
|
||
default List<XVRLDetection> getAllErrorDetections() { | ||
return getReports().stream().flatMap(xvrlReport -> xvrlReport.getAllErrorDetections().stream()).collect(Collectors.toList()); | ||
} | ||
} |
Oops, something went wrong.