Class AutoTranslateMergeServiceImpl
- java.lang.Object
-
- com.composum.ai.aem.core.impl.autotranslate.AutoTranslateMergeServiceImpl
-
- All Implemented Interfaces:
AutoTranslateMergeService
public class AutoTranslateMergeServiceImpl extends Object implements AutoTranslateMergeService
Implementation of the AutoTranslateMergeService. Provides methods to retrieve properties for resources in the context of translations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.composum.ai.aem.core.impl.autotranslate.AutoTranslateMergeService
AutoTranslateMergeService.AutoTranslateProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected com.composum.ai.backend.slingbase.AIConfigurationService
configurationService
-
Constructor Summary
Constructors Constructor Description AutoTranslateMergeServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stream<org.apache.sling.api.resource.Resource>
descendantsStream(org.apache.sling.api.resource.Resource resource)
protected String
getComponentName(org.apache.sling.api.resource.Resource resource)
Determines the jcr:title of the current component, as found by sling:resourceTypeprotected String
getComponentTitle(org.apache.sling.api.resource.Resource resource)
Determines the jcr:title , title or text of the component by searching upwards for such a property.List<AutoTranslateMergeService.AutoTranslateProperty>
getProperties(org.apache.sling.api.resource.Resource pageResource)
Recursively finds all properties from the given resource and its children that have names starting withAITranslatePropertyWrapper.AI_NEW_TRANSLATED_SUFFIX
and creates the AI Translate Property Wrapper for each.String
intelligentMerge(String language, org.apache.sling.api.resource.Resource resource, String originalSource, String newSource, String newTranslation, String currentText)
void
saveTranslation(org.apache.sling.api.resource.Resource resource, String propertyName, String content, boolean markAsMerged)
Saves the new content to a property.
-
-
-
Method Detail
-
getProperties
public List<AutoTranslateMergeService.AutoTranslateProperty> getProperties(org.apache.sling.api.resource.Resource pageResource)
Description copied from interface:AutoTranslateMergeService
Recursively finds all properties from the given resource and its children that have names starting withAITranslatePropertyWrapper.AI_NEW_TRANSLATED_SUFFIX
and creates the AI Translate Property Wrapper for each.- Specified by:
getProperties
in interfaceAutoTranslateMergeService
- Parameters:
pageResource
- the root resource to start property extraction from.- Returns:
- a list of AutoTranslateProperty instances with translation details.
-
saveTranslation
public void saveTranslation(@Nonnull org.apache.sling.api.resource.Resource resource, @Nonnull String propertyName, @Nonnull String content, @Nonnull boolean markAsMerged) throws com.day.cq.wcm.api.WCMException
Description copied from interface:AutoTranslateMergeService
Saves the new content to a property.- Specified by:
saveTranslation
in interfaceAutoTranslateMergeService
- Parameters:
resource
- the resource to save the translation to.propertyName
- the name of the property to save the translation to.content
- the new content to save.markAsMerged
- whether to mark the property as merged- Throws:
com.day.cq.wcm.api.WCMException
-
intelligentMerge
public String intelligentMerge(String language, @Nonnull org.apache.sling.api.resource.Resource resource, @Nonnull String originalSource, @Nonnull String newSource, @Nonnull String newTranslation, @Nonnull String currentText)
- Specified by:
intelligentMerge
in interfaceAutoTranslateMergeService
-
descendantsStream
protected Stream<org.apache.sling.api.resource.Resource> descendantsStream(org.apache.sling.api.resource.Resource resource)
-
getComponentName
protected String getComponentName(org.apache.sling.api.resource.Resource resource)
Determines the jcr:title of the current component, as found by sling:resourceType
-
-