use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenameConnectionNameofSalesforceOutput method renameConnections.
private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if ("FLOW".equals(currentConnection.getConnectorName())) {
//$NON-NLS-1$
String nodeUniqueName = currentConnection.getSource();
for (Object n : processType.getNode()) {
NodeType node = (NodeType) n;
if ("tSalesforceOutput".equals(node.getComponentName())) {
for (Object e : node.getElementParameter()) {
ElementParameterType p = (ElementParameterType) e;
if ("UNIQUE_NAME".equals(p.getName()) && nodeUniqueName.equals(p.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$
currentConnection.setConnectorName("MAIN");
modified = true;
}
}
}
}
}
}
if (modified) {
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenameConnectionThenRunToOnSubjobOkTask method renameConnections.
/**
* yzhang Comment method "renameConnections".
*
* @param item
* @param processType
* @throws PersistenceException
*/
private void renameConnections(Item item, ProcessType processType) throws PersistenceException {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName().equals("THEN_RUN")) {
//$NON-NLS-1$
currentConnection.setConnectorName(EConnectionType.ON_SUBJOB_OK.getName());
currentConnection.setLabel(EConnectionType.ON_SUBJOB_OK.getDefaultLinkName());
currentConnection.setLineStyle(EConnectionType.ON_SUBJOB_OK.getId());
modified = true;
}
}
if (modified) {
factory.save(item, true);
}
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class MoveStartsLinkFromPartitionerToDepartitioner method replaceConnections.
public boolean replaceConnections(Item item) throws PersistenceException {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean replaceDone = false;
boolean modified = false;
for (Object o : processType.getConnection()) {
ConnectionType currentConnection = (ConnectionType) o;
if (currentConnection.getConnectorName() != null && STARTS_CONNECTOR_NAME.equals(currentConnection.getConnectorName())) {
String source = currentConnection.getSource();
String target = currentConnection.getTarget();
NodeType recollectorNode = null;
NodeType departitionerNode = null;
NodeType partitionerNode = null;
for (Object obj : processType.getNode()) {
NodeType currentNode = (NodeType) obj;
if (currentNode.getComponentName().equals("tPartitioner") && source.equals(ComponentUtilities.getNodeUniqueName(currentNode))) {
partitionerNode = currentNode;
} else if (currentNode.getComponentName().equals("tRecollector") && target.equals(ComponentUtilities.getNodeUniqueName(currentNode))) {
recollectorNode = currentNode;
}
}
if (recollectorNode != null && partitionerNode != null) {
//know we need to migrate this one.
ElementParameterType linkedDepartitioner = ComponentUtilities.getNodeProperty(recollectorNode, "DEPART_COMPONENT");
currentConnection.setSource(linkedDepartitioner.getValue());
modified = true;
}
}
}
if (modified) {
factory.save(item, true);
replaceDone = true;
}
return replaceDone;
}
use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.
the class RenameSparkVersions method execute.
@Override
public ExecutionResult execute(Item item) {
try {
ProcessType processType = getProcessType(item);
if (processType != null) {
final ParametersType parameters = processType.getParameters();
if (parameters != null) {
boolean modified = false;
EList<ElementParameterType> elementParameters = parameters.getElementParameter();
for (int i = 0; i < elementParameters.size(); i++) {
ElementParameterType param = elementParameters.get(i);
if ("SPARK_VERSION".equals(param.getName())) {
//$NON-NLS-1$
if ("Cloudera_CDH51".equals(param.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$
param.setValue("Cloudera_CDH5_1");
modified = true;
}
if ("MAPR_410".equals(param.getValue())) {
//$NON-NLS-1$
//$NON-NLS-1$
param.setValue("MAPR410");
modified = true;
}
break;
}
}
if (modified) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
}
} catch (PersistenceException e) {
return ExecutionResult.FAILURE;
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations