Class ArtifactTypeMapper
- java.lang.Object
-
- com.sodius.oslc.server.process.types.ArtifactTypeMapper
-
public class ArtifactTypeMapper extends Object
Utility class accessing and storingArtifactTypeMapping
's.- Since:
- 3.7.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArtifactTypeMapping
getArtifactTypeMapping(String containerId, String artifactType, List<Locale> locales)
Resolves the artifact type mapping for a given container and artifact type.static Collection<ArtifactTypeMapping>
getArtifactTypeMappings(String containerId, List<Locale> locales)
Resolves the artifact type mappings for a given container.static Set<Link>
getMappedResourceTypes(String containerId, List<Locale> locales)
Gets the mapped resource types of a given container.static Set<Link>
getSupportedResourceTypes(List<Locale> locales)
Gets theapplication-supported
set of resource types.static void
offResourceTypeChange(Consumer<ResourceTypeChange> action)
Removes an action from being notified when aresource type mapping
changes.static void
onResourceTypeChange(Consumer<ResourceTypeChange> action)
Registers an action to get executed when aresource type mapping
changes.static ArtifactTypeMappings
previewImportingArtifactTypeMappings(String sourceContainerId, String targetContainerId, String targetContainerTitle, List<Locale> locales)
Takes a source containerId, a target containerId and gets the correspondingartifact type mappings
, then compares eachartifact type mapping
to create a new result of the source imported in the target.static void
removeCustomArtifactTypeMapping(String containerId, String artifactTypeId, List<Locale> locales)
Deletes customization for an artifact type mapping and notify if there is a resource type change.static void
removeCustomArtifactTypeMappings(String containerId, List<Locale> locales)
* Deletes customization for all artifact type mappings in a container and notify if there are resource type changes.static void
setArtifactTypeMapping(String containerId, ArtifactTypeMapping mapping, List<Locale> locales)
Sets or updates a customartifact type mapping
.
-
-
-
Method Detail
-
onResourceTypeChange
public static void onResourceTypeChange(Consumer<ResourceTypeChange> action)
Registers an action to get executed when aresource type mapping
changes.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
public static void offResourceTypeChange(Consumer<ResourceTypeChange> action)
Removes an action from being notified when aresource type mapping
changes.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, List<Locale> locales) throws ArtifactTypeMappingStoreException
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.locales
- the preferred Locales for label translations.- Returns:
- the corresponding mapping.
- Throws:
ArtifactTypeMappingStoreException
- if mapping cannot be resolved.
-
getArtifactTypeMappings
public static Collection<ArtifactTypeMapping> getArtifactTypeMappings(String containerId, List<Locale> locales) throws ArtifactTypeMappingStoreException
Resolves the artifact type mappings for a given container.This method must be used, instead of using directly the
store
, to get any saved custom mapping merged with the application default's.- Parameters:
containerId
- the container id.locales
- the preferred Locales for label translations.- Returns:
- the corresponding artifact type mappings of
containerId
. - Throws:
ArtifactTypeMappingStoreException
- if custom mappings cannot be resolved.
-
removeCustomArtifactTypeMapping
public static void removeCustomArtifactTypeMapping(String containerId, String artifactTypeId, List<Locale> locales) 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.
-
removeCustomArtifactTypeMappings
public static void removeCustomArtifactTypeMappings(String containerId, List<Locale> locales) 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.
-
setArtifactTypeMapping
public static void setArtifactTypeMapping(String containerId, ArtifactTypeMapping mapping, List<Locale> locales) 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.locales
- the preferred Locales for label translations.- Throws:
ArtifactTypeMappingStoreException
- if the storage fails.
-
previewImportingArtifactTypeMappings
public static ArtifactTypeMappings previewImportingArtifactTypeMappings(String sourceContainerId, String targetContainerId, String targetContainerTitle, List<Locale> locales) throws ArtifactTypeMappingStoreException
Takes a source containerId, a target containerId and gets the correspondingartifact type mappings
, then compares eachartifact type mapping
to create a new result of the source imported in the target. Identical or missingartifact type mappings
are ignored. This method returns theartifact type mappings
result, withfeedbacks
detailing the import, but nothing is stored.- Parameters:
sourceContainerId
- the source containerIdtargetContainerId
- target containerIdtargetContainerTitle
- target container title, to display infeedbacks
.locales
- the preferred Locales for label translations.- Returns:
- the resulting
artifact type mappings
from the (previewed) import. - Throws:
ArtifactTypeMappingStoreException
- Since:
- 3.9.0
-
getSupportedResourceTypes
public static Set<Link> getSupportedResourceTypes(List<Locale> locales)
Gets theapplication-supported
set of resource types.- Parameters:
locales
- the preferred Locales for label translations.- Returns:
- the application-supported resource types.
- Since:
- 3.9.0
-
getMappedResourceTypes
public static Set<Link> getMappedResourceTypes(String containerId, List<Locale> locales) throws ArtifactTypeMappingStoreException
Gets the mapped resource types of a given container.- Parameters:
containerId
- the given container id.locales
- the preferred Locales for label translations.- Returns:
- the mapped resource types of a given container.
- Throws:
ArtifactTypeMappingStoreException
- if the storage fails.- Since:
- 3.9.0
-
-