use of org.talend.core.model.process.IContextParameter in project tbd-studio-se by Talend.
the class NoSQLRepositoryContextHandlerTest method testCreateContextParameters.
@Test
public void testCreateContextParameters() throws Exception {
List<IContextParameter> varList = handler.createContextParameters("Mongo", noSqlConnection, paramSet);
int i = 0;
for (IContextParameter contextParameter : varList) {
if (contextParameter.getValue().equals("localhost")) {
assertEquals("Mongo_ReplicaHost_1", contextParameter.getName());
assertEquals(contextParameter.getType(), JavaTypesManager.STRING.getId());
i++;
} else if (contextParameter.getValue().equals("12701")) {
assertEquals("Mongo_ReplicaPort_1", contextParameter.getName());
assertEquals(contextParameter.getType(), JavaTypesManager.INTEGER.getId());
i++;
}
}
assertTrue(i == 2);
}
use of org.talend.core.model.process.IContextParameter in project tbd-studio-se by Talend.
the class HCatalogContextHandler method createContextParameters.
@Override
public List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
List<IContextParameter> varList = new ArrayList<IContextParameter>();
if (connection instanceof HCatalogConnection) {
HCatalogConnection conn = (HCatalogConnection) connection;
String paramPrefix = prefixName + ConnectionContextHelper.LINE;
String paramName = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
EHadoopParamName hcatalogParam = (EHadoopParamName) param;
paramName = paramPrefix + hcatalogParam;
switch(hcatalogParam) {
case HCatalogHostName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getHostName());
break;
case HCatalogPort:
ConnectionContextHelper.createParameters(varList, paramName, conn.getPort());
break;
case HCatalogUser:
ConnectionContextHelper.createParameters(varList, paramName, conn.getUserName());
break;
case HCatalogPassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getPassword(), JavaTypesManager.PASSWORD);
break;
case HCatalogKerPrin:
ConnectionContextHelper.createParameters(varList, paramName, conn.getKrbPrincipal());
break;
case HCatalogRealm:
ConnectionContextHelper.createParameters(varList, paramName, conn.getKrbRealm());
break;
case HCatalogDatabase:
ConnectionContextHelper.createParameters(varList, paramName, conn.getDatabase());
break;
case HcataLogRowSeparator:
ConnectionContextHelper.createParameters(varList, paramName, conn.getRowSeparator());
break;
case HcatalogFileSeparator:
ConnectionContextHelper.createParameters(varList, paramName, conn.getFieldSeparator());
break;
default:
}
}
}
createHadoopPropertiesContextVariable(prefixName, varList, conn.getHadoopProperties());
}
return varList;
}
use of org.talend.core.model.process.IContextParameter in project tbd-studio-se by Talend.
the class HdfsContextHandlerTest method testCreateContextParameters.
@Test
public void testCreateContextParameters() {
// $NON-NLS-1$
String prefixName = "testHDFS";
HDFSConnection connection = (HDFSConnection) HDFSConnectionTestUtils.createDefaultHDFSItem().getConnection();
Set<IConnParamName> paramSet = new HashSet<>();
paramSet.add(EHadoopParamName.HdfsUser);
paramSet.add(EHadoopParamName.HdfsFileSeparator);
paramSet.add(EHadoopParamName.HdfsRowSeparator);
paramSet.add(EHadoopParamName.HdfsRowHeader);
List<String> contextParameterNames = new ArrayList<>();
for (IConnParamName paramName : paramSet) {
contextParameterNames.add(prefixName + ConnectionContextHelper.LINE + paramName);
}
List<IContextParameter> contextParameters = contextHandler.createContextParameters(prefixName, connection, paramSet);
for (IContextParameter contextParameter : contextParameters) {
String contextParameterName = contextParameter.getName();
assertTrue(contextParameterNames.contains(contextParameterName));
checkContextParameter(contextParameter, connection);
}
}
use of org.talend.core.model.process.IContextParameter in project tesb-studio-se by Talend.
the class ContextPartGenerator method generatePart.
public CharSequence generatePart(IContext designerContext) throws CodeGeneratorException {
List<IContextParameter> listParameters = designerContext.getContextParameterList();
if (listParameters == null) {
return "";
}
CodeGeneratorArgument codeGenArgument = argumentBuilder.build();
codeGenArgument.setContextName(designerContext.getName());
List<IContextParameter> listParametersCopy = tranformEncryptedParams(listParameters);
codeGenArgument.setNode(listParametersCopy);
JetBean jetBean = JetUtil.createJetBean(codeGenArgument);
CodeGeneratorInternalTemplatesFactory codegenTemplatesFactory = CodeGeneratorInternalTemplatesFactoryProvider.getInstance();
if (codegenTemplatesFactory.getTemplates() == null) {
codegenTemplatesFactory.init();
}
for (TemplateUtil template : codegenTemplatesFactory.getTemplatesFromType(EInternalTemplate.CONTEXT)) {
jetBean.setJetPluginRepository(template.getJetPluginRepository());
jetBean.setTemplateRelativeUri(template.getTemplateRelativeUri());
}
return JetUtil.jetGenerate(jetBean);
}
Aggregations