use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.
the class WorkspaceConfigurationPage method updateWorkspaceTable.
private void updateWorkspaceTable() {
AbstractAppSchemaConfigurator configurator = getWizard().getProvider();
DefaultIOReporter reporter = new DefaultIOReporter(configurator.getTarget(), "Generate Temporary App-Schema Mapping", AppSchemaIO.CONTENT_TYPE_MAPPING, true);
AppSchemaMappingGenerator generator;
try {
configurator.generateMapping(reporter);
generator = configurator.getMappingGenerator();
AppSchemaDataAccessType appSchemaMapping = generator.getGeneratedMapping().getAppSchemaMapping();
List<FeatureTypeMapping> typeMappings = appSchemaMapping.getTypeMappings().getFeatureTypeMapping();
for (FeatureTypeMapping typeMapping : typeMappings) {
String[] workspaceAndType = typeMapping.getTargetElement().split(":");
String workspaceName = workspaceAndType[0];
String typeName = workspaceAndType[1];
List<Namespace> namespaces = appSchemaMapping.getNamespaces().getNamespace();
for (Namespace namespace : namespaces) {
if (workspaceName.equals(namespace.getPrefix())) {
String uri = namespace.getUri();
if (workspaceConf.hasWorkspace(uri)) {
workspaceConf.getWorkspace(uri).getFeatureTypes().add(typeName);
} else {
WorkspaceMetadata workspace = new WorkspaceMetadata(workspaceName, uri);
workspace.getFeatureTypes().add(typeName);
workspaceConf.addWorkspace(workspace);
}
}
}
}
// remove workspaces that contain no features
workspaceConf.getWorkspaces().forEach((ws) -> {
if (ws.getFeatureTypes().isEmpty()) {
workspaceConf.removeWorkspace(ws.getNamespaceUri());
}
});
workspaceTableViewer.setInput(workspaceConf.getWorkspaces());
reporter.setSuccess(true);
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
}
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.
the class AppSchemaMappingGenerator method getMainWorkspace.
/**
* Returns the generated workspace configuration for the main workspace.
*
* @return the main workspace configuration
* @throws IllegalStateException if the no app-schema mapping configuration
* has been generated yet or if no target schema is available
*/
public Workspace getMainWorkspace() {
checkMappingGenerated();
checkTargetSchemaAvailable();
Namespace ns = context.getOrCreateNamespace(targetSchema.getNamespace(), null);
Workspace ws = getWorkspace(ns.getPrefix(), ns.getUri());
return ws;
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.
the class AppSchemaMappingGenerator method getMainNamespace.
/**
* Returns the generated namespace configuration for the main namespace.
*
* @return the main namespace configuration
* @throws IllegalStateException if no app-schema mapping configuration has
* been generated yet or if no target schema is available
*/
public eu.esdihumboldt.hale.io.geoserver.Namespace getMainNamespace() {
checkMappingGenerated();
checkTargetSchemaAvailable();
Namespace ns = context.getOrCreateNamespace(targetSchema.getNamespace(), null);
return getNamespace(ns);
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.
the class AppSchemaMappingGenerator method getSecondaryNamespaces.
/**
* Returns the generated namespace configuration for secondary namespaces.
*
* @return the secondary namespaces configuration
* @throws IllegalStateException if no app-schema mapping configuration has
* been generated yet or if no target schema is available
*/
public List<eu.esdihumboldt.hale.io.geoserver.Namespace> getSecondaryNamespaces() {
checkMappingGenerated();
checkTargetSchemaAvailable();
List<eu.esdihumboldt.hale.io.geoserver.Namespace> secondaryNamespaces = new ArrayList<eu.esdihumboldt.hale.io.geoserver.Namespace>();
// for (Namespace ns : mappingWrapper.getAppSchemaMapping().getNamespaces().getNamespace()) {
for (Namespace ns : mainMapping.getNamespaces().getNamespace()) {
if (!ns.getUri().equals(targetSchema.getNamespace())) {
secondaryNamespaces.add(getNamespace(ns));
}
}
return secondaryNamespaces;
}
use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.
the class AbstractPropertyTransformationHandler method handleXmlElementAsGeometryType.
/**
* This method is invoked when the target property is a GML geometry type.
*
* <p>
* The target attribute is set to <code>gml:AbstractGeometry</code> and the
* concrete geometry type is specified in a
* <code><targetAttributeNode></code> tag.
* </p>
*
* @param featureType the target feature type
* @param mappingName the target feature type's mapping name (may be
* <code>null</code>)
* @param context the app-schema mapping context
*/
protected void handleXmlElementAsGeometryType(TypeDefinition featureType, String mappingName, AppSchemaMappingContext context) {
PropertyEntityDefinition geometry = targetProperty.getDefinition();
createGeometryAttributeMapping(featureType, mappingName, geometry, context);
// GeometryTypes require special handling
TypeDefinition geometryType = geometry.getDefinition().getPropertyType();
QName geomTypeName = geometryType.getName();
Namespace geomNS = context.getOrCreateNamespace(geomTypeName.getNamespaceURI(), geomTypeName.getPrefix());
attributeMapping.setTargetAttributeNode(geomNS.getPrefix() + ":" + geomTypeName.getLocalPart());
// set target attribute to parent (should be gml:AbstractGeometry)
// TODO: this is really ugly, but I don't see a better way to do it
// since HALE renames
// {http://www.opengis.net/gml/3.2}AbstractGeometry element
// to
// {http://www.opengis.net/gml/3.2/AbstractGeometry}choice
EntityDefinition parentEntityDef = AlignmentUtil.getParent(geometry);
Definition<?> parentDef = parentEntityDef.getDefinition();
String parentQName = geomNS.getPrefix() + ":" + parentDef.getDisplayName();
List<ChildContext> targetPropertyPath = parentEntityDef.getPropertyPath();
attributeMapping.setTargetAttribute(mapping.buildAttributeXPath(featureType, targetPropertyPath) + "/" + parentQName);
}
Aggregations