Class ArtifactTypeMapper
ArtifactTypeMapping's.- Since:
- 3.7.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic ArtifactTypeMappinggetArtifactTypeMapping(String containerId, String artifactType) Resolves the artifact type mapping for a given container and artifact type.static Collection<ArtifactTypeMapping> getContainerMappings(String containerId) Returns the merged (default + custom) artifact type mappings for a single container.static Map<String, Collection<ArtifactTypeMapping>> getContainersMappings(Set<String> containerIds) Resolves the artifact type mappings for a possibly set of containers.getMappedResourceTypes(String containerId) Gets the mapped resource types of a given container.static Optional<ResourceTypeMapping> getResourceTypeMapping(URI resourceType, String containerId) Resolves the resource type mapping for a single container.static Map<String, ResourceTypeMapping> getResourceTypeMappings(URI resourceType, Set<String> containerIds) Convenient method to resolve theArtifactTypeinstancesmapped (and non-mapped)to aResourceTypeon a given container.Gets theapplication-supportedset of resource types.static voidRemoves an action from being notified when aresource type mappingchanges.static voidRegisters an action to get executed when aresource type mappingchanges.static ArtifactTypeMappingspreviewImportingArtifactTypeMappings(String sourceContainerId, String targetContainerId, String targetContainerTitle) Takes a source containerId, a target containerId and gets the correspondingartifact type mappings, then compares eachartifact type mappingto create a new result of the source imported in the target.static voidremoveCustomArtifactTypeMapping(String containerId, String artifactTypeId) Deletes customization for an artifact type mapping and notify if there is a resource type change.static voidremoveCustomArtifactTypeMappings(String containerId) * Deletes customization for all artifact type mappings in a container and notify if there are resource type changes.static voidsetArtifactTypeMapping(String containerId, ArtifactTypeMapping mapping) Sets or updates a customartifact type mapping.
-
Method Details
-
onResourceTypeChange
Registers an action to get executed when aresource type mappingchanges.Changes that occurred before the registration are not notified, registrations should be done at application startup. All actions will be executed on a dedicated thread and no exceptions must be thrown but handled internally.
Actions are all automatically unregistered when the application is
disposed.- Parameters:
action- the action to execute.- Since:
- 3.9.0
-
offResourceTypeChange
Removes an action from being notified when aresource type mappingchanges.Actions are all automatically unregistered when the application is
disposed.- Parameters:
action- the action to execute.- Since:
- 3.9.0
-
getArtifactTypeMapping
public static ArtifactTypeMapping getArtifactTypeMapping(String containerId, String artifactType) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Resolves the artifact type mapping for a given container and artifact type.This method must be used, instead of using directly the
store, to get the saved custom mapping, if any, merged with the application default's.- Parameters:
containerId- the container id.artifactType- the artifact type id.- Returns:
- the corresponding mapping.
- Throws:
ArtifactTypeMappingStoreException- if mapping cannot be resolved.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 3.13.0
-
getContainersMappings
public static Map<String,Collection<ArtifactTypeMapping>> getContainersMappings(Set<String> containerIds) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Resolves the artifact type mappings for a possibly set of containers.This method must be used, instead of using directly the
store, to get any saved custom mapping merged with the application default's.- Parameters:
containerIds- the container id set (defaults to all containers if empty).- Returns:
- the artifact type mappings per requested container.
- Throws:
ArtifactTypeMappingStoreException- if custom mappings cannot be resolved.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 4.2.0
-
getContainerMappings
public static Collection<ArtifactTypeMapping> getContainerMappings(String containerId) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Returns the merged (default + custom) artifact type mappings for a single container.An empty collection is returned when the container id is not found or has no artifact types defined. These two cases are indistinguishable from this method's return value alone.
- Parameters:
containerId- the container id to retrieve mappings for.- Returns:
- the artifact type mappings for the given container, or an empty collection if none are found.
- Throws:
ArtifactTypeMappingStoreException- if custom mappings cannot be resolved.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 4.2.0
-
removeCustomArtifactTypeMapping
public static void removeCustomArtifactTypeMapping(String containerId, String artifactTypeId) throws ArtifactTypeMappingStoreException Deletes customization for an artifact type mapping and notify if there is a resource type change.- Parameters:
containerId- the container id.artifactTypeId- the artifactTypeId- Throws:
ArtifactTypeMappingStoreException- if the custom mapping cannot be resolved.- Since:
- 3.12.0
-
removeCustomArtifactTypeMappings
public static void removeCustomArtifactTypeMappings(String containerId) throws ArtifactTypeMappingStoreException * Deletes customization for all artifact type mappings in a container and notify if there are resource type changes.- Parameters:
containerId- the container id.- Throws:
ArtifactTypeMappingStoreException- if custom mappings cannot be resolved.- Since:
- 3.12.0
-
setArtifactTypeMapping
public static void setArtifactTypeMapping(String containerId, ArtifactTypeMapping mapping) throws ArtifactTypeMappingStoreException Sets or updates a customartifact type mapping.This method must be used, instead of using directly the
store, to avoid storing custom mappings when they are equal to the default's. This method also removes a previously saved custom mapping, if the mapping to store is equal to the default's.- Parameters:
containerId- the container id.mapping- the custom mapping.- Throws:
ArtifactTypeMappingStoreException- if the storage fails.- Since:
- 3.12.0
-
previewImportingArtifactTypeMappings
public static ArtifactTypeMappings previewImportingArtifactTypeMappings(String sourceContainerId, String targetContainerId, String targetContainerTitle) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Takes a source containerId, a target containerId and gets the correspondingartifact type mappings, then compares eachartifact type mappingto create a new result of the source imported in the target. Identical or missingartifact type mappingsare ignored. This method returns theartifact type mappingsresult, withfeedbacksdetailing the import, but nothing is stored.- Parameters:
sourceContainerId- the source containerIdtargetContainerId- target containerIdtargetContainerTitle- target container title, to display infeedbacks.- Returns:
- the resulting
artifact type mappingsfrom the (previewed) import. - Throws:
ArtifactTypeMappingStoreException- if custom mappings cannot be resolvedLinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 3.13.0
-
getSupportedResourceTypes
Gets theapplication-supportedset of resource types. This method excludesResourceType.DELIVERABLEfrom the result set, if present, as it is not a legitimate mapping resource type for an artifact type.- Returns:
- the application-supported resource types.
- Throws:
LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 3.13.0
-
getMappedResourceTypes
public static Set<Link> getMappedResourceTypes(String containerId) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Gets the mapped resource types of a given container.- Parameters:
containerId- the given container id.- Returns:
- the mapped resource types of a given container.
- Throws:
ArtifactTypeMappingStoreException- if the storage fails.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 3.13.0
-
getResourceTypeMappings
public static Map<String,ResourceTypeMapping> getResourceTypeMappings(URI resourceType, Set<String> containerIds) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Convenient method to resolve theArtifactTypeinstancesmapped (and non-mapped)to aResourceTypeon a given container.Containers where no artifact type is mapped to the requested resource type are excluded from the result; non-mapped data is only meaningful when there is at least one mapped artifact type.
- Parameters:
resourceType- the resource type.containerIds- the container ids to resolve (defaults to all containers if empty).- Returns:
- the resource type mappings per container id, excluding containers with no mapped artifact types.
- Throws:
ArtifactTypeMappingStoreException- if an error prevents the mappings or containers from being retrieved.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 4.2.0
-
getResourceTypeMapping
public static Optional<ResourceTypeMapping> getResourceTypeMapping(URI resourceType, String containerId) throws ArtifactTypeMappingStoreException, LinkingTypesStoreException Resolves the resource type mapping for a single container.An empty optional is returned when no artifact type is mapped to the requested resource type in the given container.
- Parameters:
resourceType- the resource type.containerId- the container id to resolve.- Returns:
- the resource type mapping for the given container, or an empty optional if no artifact types are mapped to the resource type.
- Throws:
ArtifactTypeMappingStoreException- if an error prevents the mappings or containers from being retrieved.LinkingTypesStoreException- if an error prevents resource types from being retrieved.- Since:
- 4.2.0
-