use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class QuoteWraptSSHcommandMigrationTask method wrapQuot.
private boolean wrapQuot(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList node = processType.getNode();
for (Object n : node) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tSSH")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (elemType.getName().equals("COMMANDS")) {
//$NON-NLS-1$
EList elemValue = elemType.getElementValue();
for (Object eVal : elemValue) {
ElementValueType elemVal = (ElementValueType) eVal;
String originV = elemVal.getValue();
//$NON-NLS-1$ //$NON-NLS-2$
elemVal.setValue("\"" + originV + "\"");
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class RemoveUnuseQuoteOnTLoop method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$
String[] componentsName = new String[] { "tLoop" };
IComponentConversion removeQuote = new IComponentConversion() {
private void removeQuote(ElementParameterType element) {
if (element != null && element.getValue() != null) {
String dValue = element.getValue();
if (dValue.startsWith("\"") && dValue.endsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
dValue = dValue.substring(1, dValue.length() - 1);
element.setValue(dValue);
}
}
}
@Override
public void transform(NodeType node) {
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
List<String> parameters = Arrays.asList(new String[] { "DECLARATION", "CONDITION", "ITERATION" });
for (String parameter : parameters) {
removeQuote(ComponentUtilities.getNodeProperty(node, parameter));
}
}
};
for (String name : componentsName) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(removeQuote));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class RenamePasswordParaForLdapMigrationTask method renamePasswordName.
private void renamePasswordName(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ProcessType processType = getProcessType(item);
for (Object object : processType.getNode()) {
if (object instanceof NodeType) {
NodeType currentNode = (NodeType) object;
if (currentNode.getComponentName().startsWith("tLDAP")) {
//$NON-NLS-1$
for (Object o : currentNode.getElementParameter()) {
ElementParameterType para = (ElementParameterType) o;
if ("PASSWD".equals(para.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
para.setName("PASS");
modified = true;
break;
}
}
}
}
}
if (modified) {
try {
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class RenameSchemaParameterForMSSqlConnectionMigrationTask method renamePasswordName.
private void renamePasswordName(Item item) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
ProcessType processType = getProcessType(item);
for (Object object : processType.getNode()) {
if (object instanceof NodeType) {
NodeType currentNode = (NodeType) object;
if (currentNode.getComponentName().startsWith("tMSSqlConnection")) {
//$NON-NLS-1$
for (Object o : currentNode.getElementParameter()) {
ElementParameterType para = (ElementParameterType) o;
if ("DB_SCHEMA".equals(para.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
para.setName("SCHEMA_DB");
modified = true;
break;
}
}
}
}
}
if (modified) {
try {
factory.save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tesb-studio-se by Talend.
the class CBeanCTalendJobMigrationTask method migrateCBean.
private boolean migrateCBean(NodeType currentNode) {
EList elementParameter = currentNode.getElementParameter();
boolean isNewElement = false;
for (Object obj : elementParameter) {
if (!(obj instanceof ElementParameterType)) {
continue;
}
ElementParameterType param = (ElementParameterType) obj;
String name = param.getName();
if ("FROM_REGISTRY".equals(name) || "FROM_CLASS".equals(name)) {
isNewElement = true;
break;
}
}
if (isNewElement) {
return false;
}
ElementParameterType fromClass = TalendFileFactory.eINSTANCE.createElementParameterType();
fromClass.setName("FROM_CLASS");
fromClass.setValue("true");
elementParameter.add(fromClass);
ElementParameterType fromRegistry = TalendFileFactory.eINSTANCE.createElementParameterType();
fromRegistry.setName("FROM_REGISTRY");
fromRegistry.setValue("false");
elementParameter.add(fromRegistry);
return true;
}
Aggregations