Skip to content

Commit

Permalink
#933 | Added special translator modifiers expr, version, system
Browse files Browse the repository at this point in the history
…, `class`
  • Loading branch information
mlytvyn authored Jan 7, 2024
1 parent 3f3d0cf commit f67d472
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- Parse and style password encoding prefixes as field value [#931](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/931)
- Suggest the next available type code when there is no value [#923](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/923)
- Improved code completion for `translator` modifier [#932](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/932)
- Added special translator modifiers `expr`, `version`, `system`, `class` [#933](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/933)

### `ImpEx` inspection rules
- Inspect type set for `disable.UniqueAttributesValidator.for.types` type modifier [#896](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/896)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.intellij.openapi.project.Project
*/
enum class AttributeModifier(
override val modifierName: String,
private val modifierValues: Set<String> = emptySet()
private val modifierValues: Set<String> = emptySet(),
) : ImpexModifier {

UNIQUE("unique", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
Expand Down Expand Up @@ -66,7 +66,11 @@ enum class AttributeModifier(
TRANSLATOR("translator") {
override fun getLookupElements(project: Project) = ImpexImplementationClassCompletionContributor.getInstance(project)
.getImplementationsForClasses(*HybrisConstants.CLASS_FQN_IMPEX_TRANSLATORS)
};
},
EXPR("expr"),
SYSTEM("system"),
VERSION("version"),
CLASSIFICATION_CLASS("class");

override fun getLookupElements(project: Project): Set<LookupElement> = modifierValues
.map { ImpExLookupElementFactory.buildModifierValue(it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
* This file is part of "SAP Commerce Developers Toolset" plugin for IntelliJ IDEA.
* Copyright (C) 2019-2024 EPAM Systems <[email protected]> and contributors
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -73,6 +73,46 @@ class ImpexDocumentationTarget(val element: PsiElement, private val originalElem

ImpexTypes.ATTRIBUTE_NAME -> {
when (element.text) {
AttributeModifier.EXPR.modifierName -> impexDoc {
typeModifier(element.text)
subHeader("VelocityTranslator")
externalLink(
"Special Value Translators",
"https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/aa417173fe4a4ba5a473c93eb730a417/4ce7b82cbc574456ac197393f88e5cc6.html?locale=en-US#special-value-translators"
)
texts(
"The VelocityTranslator is used only for export. It can be used for exporting a value for an item using a velocity expression.",
"With that, you can export a constant value or can aggregate different attributes.",
"Using the following header at an export of an order item, the code of the order is exported as well as the id and name of the user owning the order and its payment address, street name, and country.",
)
example("""
INSERT_UPDATE Order; code[unique=true]; \
@template1[translator=de.hybris.jakarta.ext.impex.jalo.translators.VelocityTranslator, expr='${"$"}item.user.getUID()']; \
@template2[translator=de.hybris.jakarta.ext.impex.jalo.translators.VelocityTranslator, expr='${"$"}item.user.name'];
""".trimIndent())
}.build()

AttributeModifier.CLASSIFICATION_CLASS.modifierName,
AttributeModifier.SYSTEM.modifierName,
AttributeModifier.VERSION.modifierName -> impexDoc {
typeModifier(element.text)
subHeader("ClassificationAttributeTranslator")
externalLink(
"Special Value Translators",
"https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/aa417173fe4a4ba5a473c93eb730a417/4ce7b82cbc574456ac197393f88e5cc6.html?locale=en-US#special-value-translators"
)
texts(
"Instead of importing each product feature one by one you can assign all features of a product with one value line using this translator.",
"Therefore you have to declare a special attribute for each feature to import.",
"Assuming you want to set a value for feature type at your product a suitable header could be as follows:",
)
example("""
UPDATE Product; code[unique=true]; @type[system='SampleClassification',version='1.0',translator=de.hybris.platform.catalog.jalo.classification.impex.ClassificationAttributeTranslator;]
""".trimIndent())
texts("In this example, the modifiers system and version, which are both mandatory, specify the classification system version of the product feature.")
texts("One more optional modifier class can be used with this translator.")
}.build()

TypeModifier.DISABLE_UNIQUE_ATTRIBUTES_VALIDATOR_FOR_TYPES.modifierName -> impexDoc {
typeModifier(element.text)
externalLink(
Expand Down

0 comments on commit f67d472

Please sign in to comment.