Repository navigation
Conversation
…nd-sheetcut-validator
…ub.com/linusbbb/set into siteplan-export-and-sheetcut-validator
…e/set/ppmodel/extensions/utils/PlanProToTitleboxTransformation.xtend Co-authored-by: TruongQuangSB <131350493+TruongQuangSB@users.noreply.github.com>
…ub.com/linusbbb/set into siteplan-export-and-sheetcut-validator
| final PlanProXMLNode node = nodeFinder.find(sheetCut); | ||
| final int line = node == null ? 0 | ||
| : nodeFinder.getLineNumber(node); | ||
| final String objektArt = nodeFinder.getObjectType(node); | ||
|
|
||
| final Polygonzug_Ausrichtung_TypeClass ausrichtung = sheetCut | ||
| .getPolygonzugAusrichtung(); | ||
| final PlanProXMLNode ausrichtungsNode = nodeFinder | ||
| .find(ausrichtung); | ||
| final int ausrichtungsLine = ausrichtungsNode == null ? line | ||
| : nodeFinder.getLineNumber(ausrichtungsNode); | ||
|
|
||
| final String wert = ausrichtung == null ? null | ||
| : ausrichtung.getWert(); | ||
| if (wert == null || wert.isBlank()) { | ||
| anyProblems = true; | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Blattschnitt ohne Ausrichtung", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, null); | ||
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
| } else { | ||
| final String[] tokens = wert.trim().split("\\s+"); //$NON-NLS-1$ | ||
| if (tokens.length != 4) { | ||
| anyProblems = true; | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| String.format( | ||
| "Ausrichtung hat %d Koordinaten (erwartet 4)", //$NON-NLS-1$ | ||
| Integer.valueOf(tokens.length)), | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, | ||
| null); | ||
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
| } | ||
| } |
There was a problem hiding this comment.
@linusbbb For better readability and easier debugging, consider extracting this validation into a separate method, such as validateDirectionLine.
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
| } else { | ||
| final String[] tokens = wert.trim().split("\\s+"); //$NON-NLS-1$ |
There was a problem hiding this comment.
@linusbbb the coordinaten string should also check, if this a number
| } | ||
| } | ||
|
|
||
| if (!anyProblems) { |
There was a problem hiding this comment.
| if (!anyProblems) { | |
| if (result.isEmpty()) { |
@linusbbb you can simple check if the list empty or not, when empty, then that mean no error
| final Polygonzug_Blattschnitt_TypeClass polygon = sheetCut | ||
| .getPolygonzugBlattschnitt(); | ||
| final PlanProXMLNode polygonNode = nodeFinder.find(polygon); | ||
| final int polygonLine = polygonNode == null ? line | ||
| : nodeFinder.getLineNumber(polygonNode); | ||
|
|
||
| final String polygonWert = polygon == null ? null | ||
| : polygon.getWert(); | ||
| if (polygonWert == null || polygonWert.isBlank()) { | ||
| anyProblems = true; | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Blattschnitt ohne Polygon", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, null); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| } else { | ||
| final String[] polygonTokens = polygonWert.trim() | ||
| .split("\\s+"); //$NON-NLS-1$ | ||
| if (polygonTokens.length % 2 != 0) { | ||
| anyProblems = true; | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| String.format( | ||
| "Polygon hat %d Koordinaten (ungerade Anzahl)", //$NON-NLS-1$ | ||
| Integer.valueOf( | ||
| polygonTokens.length)), | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, | ||
| null); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| } else if (polygonTokens.length / 2 < 3) { | ||
| anyProblems = true; | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| String.format( | ||
| "Polygon hat %d Punkte, mindestens 3 erforderlich", //$NON-NLS-1$ | ||
| Integer.valueOf( | ||
| polygonTokens.length / 2)), | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, | ||
| null); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| } | ||
| } |
| final PlanProXMLNode node = nodeFinder.find(sheetCut); | ||
| final int line = node == null ? 0 | ||
| : nodeFinder.getLineNumber(node); | ||
| final String objektArt = nodeFinder.getObjectType(node); | ||
|
|
||
| final Polygonzug_Ausrichtung_TypeClass ausrichtung = sheetCut | ||
| .getPolygonzugAusrichtung(); | ||
| final PlanProXMLNode ausrichtungsNode = nodeFinder | ||
| .find(ausrichtung); | ||
| final int ausrichtungsLine = ausrichtungsNode == null ? line | ||
| : nodeFinder.getLineNumber(ausrichtungsNode); | ||
|
|
||
| final String wert = ausrichtung == null ? null | ||
| : ausrichtung.getWert(); |
There was a problem hiding this comment.
@linusbbb u can use org.eclipse.set.ppmodel.extensions.EObjectExtensions.getNullableObject(sheetcut, s -> s.getPolygonzugAusrichtung().getWert()) to avoid more times null check
| "Blattschnitt ohne Ausrichtung", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, | ||
| this.validationType(), objektArt, null, null); | ||
| problem.setLineNumber(ausrichtungsLine); |
There was a problem hiding this comment.
@linusbbb when it is missing the information, then don't need define the linenumber
| final String[] polygonTokens = polygonWert.trim() | ||
| .split("\\s+"); //$NON-NLS-1$ |
There was a problem hiding this comment.
@linusbbb like oben, the polygon coordinate should be also validate
…e/set/ppmodel/extensions/utils/PlanProToTitleboxTransformation.xtend Co-authored-by: TruongQuangSB <131350493+TruongQuangSB@users.noreply.github.com>
No description provided.