Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.exactpro.sf.actions.ActionClassTemplateImpl Maven / Gradle / Ivy
// Autogenerated Jamon implementation
// /srv/jenkins/workspace/Sailfish/Sailfish-3.3-pipeline@2/Core/BackEnd/Core/sailfish-core/src/main/templates/com/exactpro/sf/actions/ActionClassTemplate.jamon
package com.exactpro.sf.actions;
// 3, 1
import java.util.Collection;
// 4, 1
import com.exactpro.sf.common.messages.structures.*;
public class ActionClassTemplateImpl
extends org.jamon.AbstractTemplateImpl
implements com.exactpro.sf.actions.ActionClassTemplate.Intf
{
private final String packageName;
private final String namespaceName;
private final String messagePackageName;
private final Collection messages;
private final String uncheckedFields;
protected static com.exactpro.sf.actions.ActionClassTemplate.ImplData __jamon_setOptionalArguments(com.exactpro.sf.actions.ActionClassTemplate.ImplData p_implData)
{
return p_implData;
}
public ActionClassTemplateImpl(org.jamon.TemplateManager p_templateManager, com.exactpro.sf.actions.ActionClassTemplate.ImplData p_implData)
{
super(p_templateManager, __jamon_setOptionalArguments(p_implData));
packageName = p_implData.getPackageName();
namespaceName = p_implData.getNamespaceName();
messagePackageName = p_implData.getMessagePackageName();
messages = p_implData.getMessages();
uncheckedFields = p_implData.getUncheckedFields();
}
@Override public void renderNoFlush(final java.io.Writer jamonWriter)
throws java.io.IOException
{
// 15, 1
jamonWriter.write("package ");
// 15, 9
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(packageName), jamonWriter);
// 15, 26
jamonWriter.write(";\n\nimport ");
// 17, 8
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messagePackageName), jamonWriter);
// 17, 32
jamonWriter.write(".*;\n\nimport com.exactpro.sf.common.impl.messages.BaseMessage;\nimport com.exactpro.sf.common.messages.IMessage;\n\nimport com.exactpro.sf.aml.CommonColumn;\nimport com.exactpro.sf.aml.CommonColumns;\nimport com.exactpro.sf.aml.CustomColumn;\nimport com.exactpro.sf.aml.CustomColumns;\nimport com.exactpro.sf.scriptrunner.actionmanager.actioncontext.IActionContext;\nimport com.exactpro.sf.scriptrunner.actionmanager.actioncontext.impl.ActionContextWrapper;\nimport com.exactpro.sf.aml.generator.matrix.Column;\nimport com.exactpro.sf.services.IInitiatorService;\n\nimport com.exactpro.sf.aml.script.actions.WaitAction;\n\nimport com.exactpro.sf.services.ISession;\nimport com.exactpro.sf.scriptrunner.AbstractCaller;\nimport com.exactpro.sf.scriptrunner.actionmanager.ActionMethod;\nimport com.exactpro.sf.configuration.ResourceAliases;\n\n@SuppressWarnings(\"unused\")\n@ResourceAliases({\"");
// 39, 20
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(namespaceName.toUpperCase() + "_SndRcvMatrixActions"), jamonWriter);
// 39, 78
jamonWriter.write("\"})\npublic class ");
// 40, 14
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(namespaceName.toUpperCase() + "_SndRcvMatrixActions"), jamonWriter);
// 40, 72
jamonWriter.write(" extends AbstractCaller\n{\n\t");
// 42, 2
for (IMessageStructure message: messages )
{
// 42, 46
jamonWriter.write("\n\t");
// 43, 2
String messageClassName = message.getName();
IAttributeStructure adminAttribute = message.getAttributes().get("IsAdmin");
Boolean isAdmin = adminAttribute != null ? adminAttribute.getCastValue() : null;
if (isAdmin == null) {
isAdmin = false;
}
IAttributeStructure generateActionAttribute = message.getAttributes().get("generateAction");
Boolean generateAction = generateActionAttribute != null ? generateActionAttribute.getCastValue() : null;
if (generateAction != null && !generateAction) {
continue;
}
// 60, 2
jamonWriter.write("@CommonColumns({\n @CommonColumn(Column.Reference),\n @CommonColumn(value = Column.ServiceName, required = true),\n @CommonColumn(Column.Timeout)\n })\n @CustomColumns({");
// 65, 21
boolean first = true;
// 65, 57
for (IFieldStructure field: message.getFields().values() )
{
// 65, 117
if (field.isComplex() || field.getDefaultValue() != null || !field.isRequired()) {
continue;
}
IAttributeStructure autoFilledAttribute = field.getAttributes().get("autoFilled");
Boolean autoFilled = autoFilledAttribute != null ? autoFilledAttribute.getCastValue() : null;
if (autoFilled != null && autoFilled) {
continue;
}
// 76, 10
if (!first )
{
// 76, 24
jamonWriter.write(", ");
}
// 76, 26
else
{
// 76, 33
first=false;
}
// 76, 66
jamonWriter.write("@CustomColumn(value = \"");
// 76, 89
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(field.getName()), jamonWriter);
// 76, 110
jamonWriter.write("\", required = true)");
}
// 76, 136
jamonWriter.write("})\n\t@ActionMethod\n\tpublic ");
// 78, 9
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 78, 31
jamonWriter.write(" ");
// 78, 32
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(namespaceName.toUpperCase() + "_Send" + messageClassName), jamonWriter);
// 78, 94
jamonWriter.write(" (\n\t\tIActionContext actionContext, \n\t\t");
// 80, 3
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 80, 25
jamonWriter.write(" message) \n\tthrows Exception {\n\t\treturn (");
// 82, 11
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 82, 33
jamonWriter.write(") send(actionContext, message, \"");
// 82, 65
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 82, 87
jamonWriter.write("\");\n\t}\n\n \n\t@CommonColumns({\n @CommonColumn(Column.Reference),\n @CommonColumn(value = Column.ServiceName, required = true),\n @CommonColumn(Column.Timeout)\n })\n\t@ActionMethod\n\tpublic ");
// 92, 9
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 92, 31
jamonWriter.write(" ");
// 92, 32
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(namespaceName.toUpperCase() + "_Wait" + messageClassName), jamonWriter);
// 92, 94
jamonWriter.write(" (\n\t\tIActionContext actionContext, \n\t\t");
// 94, 3
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 94, 25
jamonWriter.write(" message) \n\tthrows Exception {\n\t\tIMessage im = receive(actionContext, message, ");
// 96, 49
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(isAdmin), jamonWriter);
// 96, 62
jamonWriter.write(");\n\t\treturn new ");
// 97, 14
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 97, 36
jamonWriter.write("(im);\n\t}\n\t\n\t@CommonColumns({\n @CommonColumn(Column.CheckPoint),\n @CommonColumn(Column.DoublePrecision),\n @CommonColumn(value = Column.MessageCount, required = true),\n @CommonColumn(value = Column.ServiceName, required = true),\n @CommonColumn(Column.SystemPrecision),\n @CommonColumn(value = Column.Timeout, required = true)\n })\n\t@ActionMethod\n\tpublic void ");
// 109, 14
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(namespaceName.toUpperCase() + "_Count" + messageClassName), jamonWriter);
// 109, 77
jamonWriter.write("(\n\t\t\tIActionContext actionContext, \n\t\t\t");
// 111, 4
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(messageClassName), jamonWriter);
// 111, 26
jamonWriter.write(" message) \n\tthrows Exception {\n\t\tcountMessages(actionContext, message, ");
// 113, 41
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(isAdmin), jamonWriter);
// 113, 54
jamonWriter.write(");\n\t}\n\t");
}
// 115, 9
jamonWriter.write("\n\n\n\tprivate static IInitiatorService getClient(IActionContext actionContext)\n\t{\n\t\treturn ActionUtil.getService(actionContext, IInitiatorService.class);\n\t}\n\n\tprivate static BaseMessage send(IActionContext actionContext, BaseMessage message, String msgName) throws Exception\n\t{\n\t\tString serviceName = actionContext.getServiceName();\n\t\tIInitiatorService client = getClient(actionContext);\n\t\tactionContext.getLogger().info(\"client instance [{}] has been obtained.\", serviceName);\n\t\tactionContext.getLogger().info(\"actionContext [{}]\", actionContext);\n\t\tactionContext.getLogger().info(\"{}: [{}]\", msgName, message.getMessage());\n\t\tThread.sleep(actionContext.getTimeout());\n\t\tISession session = client.getSession();\n\t\tsession.send(message.getMessage()); //\n\t\tactionContext.getLogger().info(\"[{}] has successfully sent {} message.\", serviceName, msgName);\n\t\treturn message;\n\t}\n\t\n\t\n\tprivate static IMessage receive(\n\t\tIActionContext actionContext, \n\t\tBaseMessage messageFilter,\n\t\tboolean isAdmin)\n\tthrows Exception {\n IInitiatorService client = getClient(actionContext);\n ActionContextWrapper actionContextWrapper = new ActionContextWrapper(actionContext);\n actionContextWrapper.setUncheckedFields(");
// 145, 49
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(uncheckedFields), jamonWriter);
// 145, 70
jamonWriter.write(");\n messageFilter.getMessage().getMetaData().setAdmin(isAdmin);\n\t\treturn client.receive(actionContextWrapper, messageFilter.getMessage());\n\t}\n\n\tprivate static void countMessages(\n\t\t\t\tIActionContext actionContext,\n\t\t\t\tBaseMessage message,\n\t\t\t\tboolean isAdmin) throws Exception\n\t{\n\t\tboolean isApp = !isAdmin;\n\t\tWaitAction.countMessages(actionContext, message.getMessage(), isApp);\n\t}\n\n}\n\n");
}
}