use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class FileInputRegexContextVariableMigrationTaskForSave method removeQuote.
private boolean removeQuote(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList nodes = processType.getNode();
for (Object n : nodes) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tFileInputRegex")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (//$NON-NLS-1$ //$NON-NLS-2$
elemType.getName().equals("HEADER") || elemType.getName().equals("FOOTER") || elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
String oldV = elemType.getValue();
if (oldV != null && oldV.startsWith("\"") && oldV.endsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
elemType.setValue(oldV.substring(1, oldV.length() - 1));
modified = true;
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class MigrationTaskForIssue10862 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$ //$NON-NLS-2$
String[] componentsName = new String[] { "tPatternCheck", "tPatternExtract" };
for (String name : componentsName) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType patternList = ComponentUtilities.getNodeProperty(node, "PATTERN_LIST");
if (ComponentUtilities.getNodeProperty(node, "CUSTOM_PATTERN") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "CUSTOM_PATTERN", "CHECK");
}
//$NON-NLS-1$
ElementParameterType customPattern = ComponentUtilities.getNodeProperty(node, "CUSTOM_PATTERN");
if (patternList != null && patternList.getValue().equals("\"CUSTOM2\"")) {
//$NON-NLS-1$
//$NON-NLS-1$
customPattern.setValue("true");
} else {
//$NON-NLS-1$
customPattern.setValue("false");
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class MigrationTaskForIssue11632 method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentFilter filter = new NameComponentFilter("tLDAPOutput");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "USE_ATTRIBUTE_OPTIONS") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "USE_ATTRIBUTE_OPTIONS", "CHECK");
}
ElementParameterType useAttributeOptions = ComponentUtilities.getNodeProperty(node, //$NON-NLS-1$
"USE_ATTRIBUTE_OPTIONS");
//$NON-NLS-1$
ElementParameterType attributeOptions = ComponentUtilities.getNodeProperty(node, "ATTRIBUTE_OPTIONS");
if (attributeOptions == null) {
//$NON-NLS-1$
useAttributeOptions.setValue("false");
} else {
if (attributeOptions.getElementValue().size() == 0) {
//$NON-NLS-1$
useAttributeOptions.setValue("false");
} else {
//$NON-NLS-1$
useAttributeOptions.setValue("true");
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class MigrationTaskForIssue18419 method execute.
@Override
public ExecutionResult execute(final Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tFileUnarchive");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
Project pro = ProxyRepositoryFactory.getInstance().getProject(item);
String proName = pro.getLabel();
//$NON-NLS-1$
ElementParameterType zipFile = ComponentUtilities.getNodeProperty(node, "ZIPFILE");
String zipFileName = zipFile.getValue();
final String oldValues = getOldValues();
if (proName != null && !proName.equals(getDemoProjectName()) && zipFileName != null && zipFileName.equals(oldValues)) {
zipFile.setValue(oldValues.replaceFirst(getDemoProjectName(), proName));
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class MigrationTaskForIssue7547 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$
IComponentFilter filter = new NameComponentFilter("tAlfrescoOutput");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType url = ComponentUtilities.getNodeProperty(node, "ALFRESCO_SERVER_URL");
//$NON-NLS-1$
ElementParameterType userLogin = ComponentUtilities.getNodeProperty(node, "ALFRESCO_USER_LOGIN");
ElementParameterType userPassword = ComponentUtilities.getNodeProperty(node, //$NON-NLS-1$
"ALFRESCO_USER_PASSWORD");
//$NON-NLS-1$ //$NON-NLS-2$
url.setValue("\"" + url.getValue() + "\"");
//$NON-NLS-1$ //$NON-NLS-2$
userLogin.setValue("\"" + userLogin.getValue() + "\"");
//$NON-NLS-1$ //$NON-NLS-2$
userPassword.setValue("\"" + userPassword.getValue() + "\"");
}
}));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
Aggregations