forked from deegree/deegree3
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate GmlTool into deegree3 repository (deegree#1229)
* Skip GML reference resolving for WFS-T (deegree#134) * fix resolving if referenceResolvingMode = CHECK_ALL * Add documentation for UseExistingSkipResolvingReferences * #6535 - limitation if occurrence is zero or one * #6535 - added option to pass reference data * #6535 - moved content of deegree-cli-utility Tool readme to deegree-webservices-handbook * #6535 - enhanced documentation * #6535 - added link to handbook and download link * #7702 - enhanced documentation of referenceData * #7692 (PR#158) - access of the transaction in SQLFeatureStore * #7841 (deegree#1217) - moved module deegree-spring to uncoupled * #7841 - added GmlTool as new module * #7841 (deegree#1217) - removed deegree-spring from modules * #7841 - replaced spring-parent * #7481 - added reference data * #7841 - removed deegree-tools-config * #7841 - removed release pkugin, fixed spring-boot-maven-plugin * 7841 - fixed instantiation of reference data * #18 - limit generated mapping to feature types in the refernce data * #7841 - added jaxb-api dependency * #18 - limit generated mapping to feature types in the refernce data * #18 - enhanced documentation * #7841 - removed duplicated documentation * #7841 - removed duplicated documentation * #7841 - fixed jaxb dependencies * #7841 Remove oracle profile from deegree-tools Co-authored-by: Lyn Elisa Goltz <goltz@lat-lon.de> Co-authored-by: tfr42 <torsten.friebe@gmail.com>
- Loading branch information
1 parent
bc72c5f
commit 7b2765d
Showing
72 changed files
with
11,129 additions
and
633 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
95 changes: 95 additions & 0 deletions
95
...estore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/GmlReferenceData.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,95 @@ | ||
package org.deegree.feature.persistence.sql.mapper; | ||
|
||
import org.deegree.commons.tom.ElementNode; | ||
import org.deegree.commons.tom.TypedObjectNode; | ||
import org.deegree.commons.tom.gml.property.Property; | ||
import org.deegree.cs.exceptions.UnknownCRSException; | ||
import org.deegree.feature.Feature; | ||
import org.deegree.feature.FeatureCollection; | ||
import org.deegree.feature.types.FeatureType; | ||
import org.deegree.gml.GMLInputFactory; | ||
import org.deegree.gml.GMLStreamReader; | ||
import org.deegree.gml.GMLVersion; | ||
|
||
import javax.xml.namespace.QName; | ||
import javax.xml.stream.XMLStreamException; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> | ||
*/ | ||
public class GmlReferenceData implements ReferenceData { | ||
|
||
private Map<QName, List<Feature>> features; | ||
|
||
public GmlReferenceData( URL referenceData ) | ||
throws IOException, XMLStreamException, UnknownCRSException { | ||
GMLStreamReader gmlStreamReader = GMLInputFactory.createGMLStreamReader( GMLVersion.GML_32, referenceData ); | ||
FeatureCollection featureCollection = gmlStreamReader.readFeatureCollection(); | ||
this.features = featureCollection.stream().collect( Collectors.groupingBy( Feature::getName ) ); | ||
} | ||
|
||
@Override | ||
public boolean hasZeroOrOneProperty( QName featureTypeName, List<QName> xpath ) { | ||
List<Feature> featuresOfType = this.features.get( featureTypeName ); | ||
if ( featuresOfType != null && !featuresOfType.isEmpty() ) { | ||
for ( Feature feature : featuresOfType ) { | ||
if ( hasMoreThanOne( feature, xpath ) ) | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean shouldFeatureTypeMapped( QName featureTypeName ) { | ||
return features.containsKey( featureTypeName ); | ||
} | ||
|
||
private boolean hasMoreThanOne( Feature feature, List<QName> xpath ) { | ||
if ( xpath.isEmpty() ) | ||
return true; | ||
Iterator<QName> iterator = xpath.iterator(); | ||
QName firstProperty = iterator.next(); | ||
List<Property> properties = feature.getProperties( firstProperty ); | ||
return hasMoreThanOne( iterator, properties ); | ||
} | ||
|
||
private <T extends ElementNode> boolean hasMoreThanOne( Iterator<QName> iterator, List<T> properties ) { | ||
if ( !iterator.hasNext() ) { | ||
if ( properties.size() > 1 ) | ||
return true; | ||
else | ||
return false; | ||
} else { | ||
QName next = iterator.next(); | ||
for ( ElementNode property : properties ) { | ||
List<ElementNode> subProperties = getChildsByName( property, next ); | ||
if ( hasMoreThanOne( iterator, subProperties ) ) | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
private List<ElementNode> getChildsByName( ElementNode property, QName propertyName ) { | ||
List<ElementNode> properties = new ArrayList<>(); | ||
List<TypedObjectNode> children = property.getChildren(); | ||
for ( TypedObjectNode child : children ) { | ||
if ( child instanceof ElementNode ) { | ||
QName name = ( (ElementNode) child ).getName(); | ||
if ( name.equals( propertyName ) ) | ||
properties.add( (ElementNode) child ); | ||
} | ||
} | ||
return properties; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...turestore-sql/src/main/java/org/deegree/feature/persistence/sql/mapper/ReferenceData.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,27 @@ | ||
package org.deegree.feature.persistence.sql.mapper; | ||
|
||
import javax.xml.namespace.QName; | ||
import java.util.List; | ||
|
||
/** | ||
* @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a> | ||
*/ | ||
public interface ReferenceData { | ||
|
||
/** | ||
* @param featureTypeName | ||
* the name of the feature type, never <code>null</code> | ||
* @param xpath | ||
* the steps describing the path to the feature, may be empty. but never <code>null</code> | ||
* @return <code>true</code> if the property identified by the path occurs one or zero times, <code>false</code> otherwise | ||
*/ | ||
boolean hasZeroOrOneProperty( QName featureTypeName, List<QName> xpath ); | ||
|
||
/** | ||
* @param featureTypeName | ||
* the name of the feature type, never <code>null</code> | ||
* @return <code>true</code> if the feature type with this name should be mapped, <code>false</code> otherwise | ||
*/ | ||
boolean shouldFeatureTypeMapped( QName featureTypeName ); | ||
|
||
} |
Oops, something went wrong.