Search in sources :

Example 1 with Namespace

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);
    }
}
Also used : DefaultIOReporter(eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter) WorkspaceMetadata(eu.esdihumboldt.hale.io.appschema.model.WorkspaceMetadata) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) AbstractAppSchemaConfigurator(eu.esdihumboldt.hale.io.appschema.writer.AbstractAppSchemaConfigurator) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace) AppSchemaDataAccessType(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType) AppSchemaMappingGenerator(eu.esdihumboldt.hale.io.appschema.writer.AppSchemaMappingGenerator)

Example 2 with Namespace

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;
}
Also used : Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace) Workspace(eu.esdihumboldt.hale.io.geoserver.Workspace)

Example 3 with Namespace

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);
}
Also used : Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)

Example 4 with Namespace

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;
}
Also used : ArrayList(java.util.ArrayList) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)

Example 5 with Namespace

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>&lt;targetAttributeNode&gt;</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);
}
Also used : PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) QName(javax.xml.namespace.QName) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

Namespace (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)11 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)3 FeatureTypeMapping (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping)3 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)2 AppSchemaDataAccessType (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AppSchemaDataAccessType)2 ArrayList (java.util.ArrayList)2 DefaultIOReporter (eu.esdihumboldt.hale.common.core.io.report.impl.DefaultIOReporter)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 ClientProperty (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.AttributeMappingType.ClientProperty)1 DataStore (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore)1 AttributeMappings (eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping.AttributeMappings)1 WorkspaceMetadata (eu.esdihumboldt.hale.io.appschema.model.WorkspaceMetadata)1 AbstractAppSchemaConfigurator (eu.esdihumboldt.hale.io.appschema.writer.AbstractAppSchemaConfigurator)1 AppSchemaMappingGenerator (eu.esdihumboldt.hale.io.appschema.writer.AppSchemaMappingGenerator)1 Workspace (eu.esdihumboldt.hale.io.geoserver.Workspace)1 QName (javax.xml.namespace.QName)1