在Java代码中使用Hybris执行Groovy脚本的可能性(无HAC)
我想知道是否有一种方法可以用Hybris执行时髦的脚本。我知道如何使用Hybris Administration Console(HAC)执行Groovy脚本,但是我需要一个解决方案来从Java代码执行此类脚本。最好使用Patching Framework的@SystemSetup,但不是必需的。 ( ttps://help.sap.com/docs /SAP_Commerce/D0224ECA81E249CB821F2CDF45A82ACE/5DB22427A1D541669BC4D12793A7B672.HTML
?
@SystemSetup(extension = SampleCoreConstants.EXTENSIONNAME)
public class CoreSystemSetup extends AbstractSystemSetup {
public static final String IMPORT_ACCESS_RIGHTS = "accessRights";
@SystemSetup(type = Type.ESSENTIAL, process = Process.ALL)
public void createEssentialData(final SystemSetupContext context)
{
importImpexFile(context, "/samplecore/import/common/file-name.impex");
}
@Override
@SystemSetupParameterMethod
public List<SystemSetupParameter> getInitializationOptions()
{
final List<SystemSetupParameter> params = new ArrayList<>();
params.add(createBooleanSystemSetupParameter(IMPORT_ACCESS_RIGHTS, "Import Users & Groups", true));
return params;
}
TPS ://www.stackextend.com/hybris/run-native-sql-query-hybris/“ rel =” nofollow noreferrer“> https://www.stackextend.com/hybris/hhybris/run-native-sql-quer-sql-query-hybris /
因此,欢迎任何可以帮助我解决解决方案的人(或有明确的答案)。
谢谢!
I'm wondering if there is a way to execute a groovy script with Hybris. I know how groovy scripts are executed with the Hybris Administration Console (hAC), but I need a solution to execute such a script from java code. Preferably with the Patching Framework's @SystemSetup but not necessary. (https://help.sap.com/docs/SAP_COMMERCE/d0224eca81e249cb821f2cdf45a82ace/5db22427a1d541669bc4d12793a7b672.html?locale=en-US)
I'm looking for a method similar to Impex import (eg. from core extension):
@SystemSetup(extension = SampleCoreConstants.EXTENSIONNAME)
public class CoreSystemSetup extends AbstractSystemSetup {
public static final String IMPORT_ACCESS_RIGHTS = "accessRights";
@SystemSetup(type = Type.ESSENTIAL, process = Process.ALL)
public void createEssentialData(final SystemSetupContext context)
{
importImpexFile(context, "/samplecore/import/common/file-name.impex");
}
@Override
@SystemSetupParameterMethod
public List<SystemSetupParameter> getInitializationOptions()
{
final List<SystemSetupParameter> params = new ArrayList<>();
params.add(createBooleanSystemSetupParameter(IMPORT_ACCESS_RIGHTS, "Import Users & Groups", true));
return params;
}
Here the same with SQL: https://www.stackextend.com/hybris/run-native-sql-query-hybris/
So anyone who can help me out with a solution (or with a clear answer if this is possible or not) are welcome.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以在您的代码中运行Groovy。甚至在SystemSetup中。
您可以使用Hybris服务(Spring Bean)
de.hybris.platform.scripting.engine.scriptinglanguagesservice
这可以在
代码中的
Processing
扩展程序中可用,这可能是这样的事情,将在您的类路径中的给定位置上执行脚本。如果您的class路径中的文件中没有凹槽,则可能还有其他内容类型。例如:siglescriptcontent
It's possible to run groovy in your code. Even in SystemSetup.
You can use the hybris service (spring bean)
de.hybris.platform.scripting.engine.ScriptingLanguagesService
that's available in the
processing
extensionIn the code, this could be something like
This will execute a script on the given location in your classpath. If you don't have your groovy in a file in your classpath, there are other Content types possible. For example: SimpleScriptContent
有很多可以执行Groovy脚本。
方式1:
方式2:
我们可以使用以下简单方法来实现。
这是示例代码:
方式3:
如果您想要OOB ONE,则 ScriptingJobperformable 是OOB类,您可以从中参考。
请参阅
There are many to execute groovy script.
WAY 1:
WAY 2 :
We can use simple method as below to achieve.
Here is the sample code:
WAY 3 :
If you want the OOB one, ScriptingJobPerformable is the OOB class which you can take reference from that.
Please refer Scripting Engine for detailed explanation