Repository navigation
Siteplan export and sheetcut validator #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
linusbbb
wants to merge
26
commits into
eclipse-set:main
Choose a base branch
from
linusbbb:siteplan-export-and-sheetcut-validator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,258
−7,012
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
05c6a6a
filter empty sheetcuts
linusbbb 004f112
wrap export in try catch, account for missing direction line in sheetcut
linusbbb fc24af4
add validator for sheetcuts
linusbbb f707bd1
Merge remote-tracking branch 'origin/set/main' into siteplan-export-a…
linusbbb e84203a
fix siteplan export when attachment provider is missing
linusbbb 5ac5db1
Merge branch 'eclipse-set:main' into siteplan-export-and-sheetcut-val…
linusbbb 5a440da
Fix java/xtend formatting
linusbbb b11420f
Merge branch 'siteplan-export-and-sheetcut-validator' of https://gith…
linusbbb 287c857
don't use polygon anchor if real direction line exists
linusbbb c0427b3
Update java/bundles/org.eclipse.set.ppmodel.extensions/src/org/eclips…
linusbbb 2dac9c1
update validation view reference
linusbbb 27a3221
Merge branch 'siteplan-export-and-sheetcut-validator' of https://gith…
linusbbb 9d6d4bb
Update java/bundles/org.eclipse.set.ppmodel.extensions/src/org/eclips…
linusbbb 32f851c
Merge branch 'eclipse-set:main' into siteplan-export-and-sheetcut-val…
linusbbb 953c766
extract validation of direction line into seperate metjod
linusbbb f8306fb
check if coordinates are numeric in sheet cut validation
linusbbb 7cbe186
extract validation of polygon into separate method
linusbbb 88e8871
use getNullableObject for null checks
linusbbb 74b1cfc
check if polygon coordinates are numeric, share one regex for both nu…
linusbbb 9c65f11
Merge branch 'eclipse-set:main' into siteplan-export-and-sheetcut-val…
linusbbb f5954e1
Update java/bundles/org.eclipse.set.feature.validation/src/org/eclips…
linusbbb d9b7411
fix formatting
linusbbb 3a1fb8e
add object scope and state to the sheet cut problems
linusbbb d08430b
remove duplicate node finding logic
linusbbb bcfb571
rename booleam methods
linusbbb efb330a
add line number again for "Blattschnitt ohne Ausrichtung"
linusbbb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
211 changes: 211 additions & 0 deletions
211
...ipse.set.feature.validation/src/org/eclipse/set/feature/validation/SheetCutValidator.java
This file contains hidden or 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,211 @@ | ||
| /** | ||
| * Copyright (c) 2026 DB InfraGO AG and others | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v2.0 which is available at | ||
| * https://www.eclipse.org/legal/epl-2.0. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| */ | ||
| package org.eclipse.set.feature.validation; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| import org.eclipse.set.basis.PlanProXMLNode; | ||
| import org.eclipse.set.basis.constants.ValidationResult; | ||
| import org.eclipse.set.basis.files.ToolboxFile; | ||
| import org.eclipse.set.core.services.validation.CustomValidator; | ||
| import org.eclipse.set.model.planpro.Layoutinformationen.Lageplan_Blattschnitt; | ||
| import org.eclipse.set.model.planpro.Layoutinformationen.PlanPro_Layoutinfo; | ||
| import org.eclipse.set.model.planpro.Layoutinformationen.Polygonzug_Ausrichtung_TypeClass; | ||
| import org.eclipse.set.model.planpro.Layoutinformationen.Polygonzug_Blattschnitt_TypeClass; | ||
| import org.eclipse.set.model.validationreport.ObjectScope; | ||
| import org.eclipse.set.model.validationreport.ObjectState; | ||
| import org.eclipse.set.model.validationreport.ValidationSeverity; | ||
| import org.eclipse.set.ppmodel.extensions.EObjectExtensions; | ||
| import org.eclipse.set.utils.xml.EObjectXMLFinder; | ||
| import org.osgi.service.component.annotations.Component; | ||
|
|
||
| /** | ||
| * | ||
| * @author brombacher | ||
| */ | ||
| @Component(immediate = true, service = CustomValidator.class) | ||
| public class SheetCutValidator extends AbstractCustomValidator { | ||
| public static final String SHEET_CUT_VALIDATION_TYPE = "Blattschnitte"; //$NON-NLS-1$ | ||
|
|
||
| private static final String NUMBER_REGEX = "-?\\d+(\\.\\d+)?"; //$NON-NLS-1$ | ||
|
|
||
| @Override | ||
| public void validate(final ToolboxFile toolboxFile, | ||
| final ValidationResult result, final FileType type) { | ||
| try { | ||
|
|
||
| if (type != FileType.Layout) { | ||
| return; | ||
| } | ||
|
|
||
| final PlanPro_Layoutinfo layoutInfo = EObjectExtensions | ||
| .getNullableObject(toolboxFile, | ||
| t -> t.getLayoutDocumentRoot() | ||
| .getPlanProLayoutinfo()) | ||
| .orElse(null); | ||
|
|
||
| if (layoutInfo == null) { | ||
| return; | ||
| } | ||
|
|
||
| final List<Lageplan_Blattschnitt> sheetCuts = layoutInfo | ||
| .getLageplanBlattschnitt(); | ||
|
|
||
| if (sheetCuts.isEmpty()) { | ||
| result.addCustomProblem(new CustomValidationProblemImpl( | ||
| "Keine Blattschnitte vorhanden", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), null, | ||
| ObjectScope.LAYOUT, ObjectState.NONE)); | ||
| } else { | ||
| final EObjectXMLFinder nodeFinder = new EObjectXMLFinder( | ||
| toolboxFile, toolboxFile.getLayoutPath()); | ||
| boolean anyProblems = false; | ||
| for (final Lageplan_Blattschnitt sheetCut : sheetCuts) { | ||
|
|
||
| final PlanProXMLNode node = nodeFinder.find(sheetCut); | ||
| final int line = node == null ? 0 | ||
| : nodeFinder.getLineNumber(node); | ||
| final String objektArt = nodeFinder.getObjectType(node); | ||
|
|
||
| anyProblems |= isInvalidDirectionLine(result, nodeFinder, | ||
| sheetCut, line, objektArt); | ||
| anyProblems |= isInvalidPolygon(result, nodeFinder, | ||
| sheetCut, line, objektArt); | ||
| } | ||
|
|
||
| if (!anyProblems) { | ||
| result.addCustomProblem(getSuccessValidationReport( | ||
| String.format("%d Blattschnitte sind vorhanden", //$NON-NLS-1$ | ||
| Integer.valueOf(sheetCuts.size())))); | ||
| } | ||
| } | ||
| } catch (final Exception ex) { | ||
| result.addCustomProblem(new CustomValidationProblemImpl( | ||
| "Blattschnitte konnten nicht geprüft werden", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), null, | ||
| ObjectScope.LAYOUT, ObjectState.NONE)); | ||
| } | ||
| } | ||
|
|
||
| private boolean isInvalidDirectionLine(final ValidationResult result, | ||
| final EObjectXMLFinder finder, final Lageplan_Blattschnitt sheetCut, | ||
| final int line, final String objektArt) | ||
| throws EObjectXMLFinder.LineNotFoundException { | ||
|
|
||
| final Polygonzug_Ausrichtung_TypeClass ausrichtung = sheetCut | ||
| .getPolygonzugAusrichtung(); | ||
| final PlanProXMLNode ausrichtungsNode = finder.find(ausrichtung); | ||
| final int ausrichtungsLine = ausrichtungsNode == null ? line | ||
| : finder.getLineNumber(ausrichtungsNode); | ||
|
|
||
| final String wert = EObjectExtensions | ||
| .getNullableObject(sheetCut, | ||
| s -> s.getPolygonzugAusrichtung().getWert()) | ||
| .orElse(null); | ||
|
|
||
| if (wert == null || wert.isBlank()) { | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Blattschnitt ohne Ausrichtung", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), | ||
| objektArt, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
|
linusbbb marked this conversation as resolved.
|
||
| return true; | ||
| } | ||
| final String[] tokens = wert.trim().split("\\s+"); //$NON-NLS-1$ | ||
| if (tokens.length != 4) { | ||
| 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, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } | ||
| if (Arrays.stream(tokens).anyMatch(t -> !t.matches(NUMBER_REGEX))) { | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Ausrichtung hat nicht numerische Koordinaten", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), | ||
| objektArt, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(ausrichtungsLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private boolean isInvalidPolygon(final ValidationResult result, | ||
| final EObjectXMLFinder finder, final Lageplan_Blattschnitt sheetCut, | ||
| final int line, final String objektArt) | ||
| throws EObjectXMLFinder.LineNotFoundException { | ||
| final Polygonzug_Blattschnitt_TypeClass polygon = sheetCut | ||
| .getPolygonzugBlattschnitt(); | ||
| final PlanProXMLNode polygonNode = finder.find(polygon); | ||
| final int polygonLine = polygonNode == null ? line | ||
| : finder.getLineNumber(polygonNode); | ||
|
|
||
| final String polygonWert = EObjectExtensions | ||
| .getNullableObject(sheetCut, | ||
| s -> s.getPolygonzugBlattschnitt().getWert()) | ||
| .orElse(null); | ||
| if (polygonWert == null || polygonWert.isBlank()) { | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Blattschnitt ohne Polygon", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), | ||
| objektArt, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } | ||
|
|
||
| final String[] polygonTokens = polygonWert.trim().split("\\s+"); //$NON-NLS-1$ | ||
| if (polygonTokens.length % 2 != 0) { | ||
| 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, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } else if (polygonTokens.length / 2 < 3) { | ||
| 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, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } | ||
| if (Arrays.stream(polygonTokens) | ||
| .anyMatch(t -> !t.matches(NUMBER_REGEX))) { | ||
| final CustomValidationProblemImpl problem = new CustomValidationProblemImpl( | ||
| "Polygon hat nicht numerische Koordinaten", //$NON-NLS-1$ | ||
| ValidationSeverity.WARNING, this.validationType(), | ||
| objektArt, ObjectScope.LAYOUT, ObjectState.NONE); | ||
| problem.setLineNumber(polygonLine); | ||
| result.addCustomProblem(problem); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public String validationType() { | ||
| return SHEET_CUT_VALIDATION_TYPE; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.