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);
}
Aggregations