Search in sources :

Example 11 with Namespace

use of eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace in project hale by halestudio.

the class AppSchemaMappingWrapper method getOrCreateFeatureTypeMapping.

/**
 * Return the feature type mapping associated to the provided type and
 * mapping name.
 *
 * <p>
 * If a feature type mapping for the provided type and mapping name already
 * exists, it is returned; otherwise, a new one is created.
 * </p>
 *
 * @param targetType the target type
 * @param mappingName the mapping name
 * @return the feature type mapping
 */
FeatureTypeMapping getOrCreateFeatureTypeMapping(TypeDefinition targetType, String mappingName) {
    if (targetType == null) {
        return null;
    }
    Integer hashKey = getFeatureTypeMappingHashKey(targetType, mappingName);
    if (!featureTypeMappings.containsKey(hashKey)) {
        // create
        FeatureTypeMapping featureTypeMapping = new FeatureTypeMapping();
        // initialize attribute mappings member
        featureTypeMapping.setAttributeMappings(new AttributeMappings());
        // TODO: how do I know the datasource from which data will be read?
        featureTypeMapping.setSourceDataStore(getDefaultDataStore().getId());
        // Retrieve namespace this feature type belongs to and prepend its
        // prefix to the feature type name; if a namespace with the same URI
        // already existed with a valid prefix, that will be used instead of
        // the one passed here
        Namespace ns = getOrCreateNamespace(targetType.getName().getNamespaceURI(), targetType.getName().getPrefix());
        // TODO: I'm getting the element name with
        // targetType.getDisplayName():
        // isn't there a more elegant (and perhaps more reliable) way to
        // know which element corresponds to a type?
        featureTypeMapping.setTargetElement(ns.getPrefix() + ":" + targetType.getDisplayName());
        if (mappingName != null && !mappingName.isEmpty()) {
            featureTypeMapping.setMappingName(mappingName);
        }
        appSchemaMapping.getTypeMappings().getFeatureTypeMapping().add(featureTypeMapping);
        featureTypeMappings.put(hashKey, featureTypeMapping);
        addToFeatureTypeMappings(targetType, featureTypeMapping);
    }
    return featureTypeMappings.get(hashKey);
}
Also used : AttributeMappings(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping.AttributeMappings) FeatureTypeMapping(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.TypeMappingsPropertyType.FeatureTypeMapping) Namespace(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.NamespacesPropertyType.Namespace)

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