use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ReplaceMultiFlowBytReplicateMigrationTask method createNodeType.
/**
* DOC nrousseau Comment method "createNodeType".
*
* @param processType
* @param replicatePos
* @param nodeTypeSource
* @param sourceName
* @param nodeConnector
* @param connections
* @param fileFact
* @return
*/
private String createNodeType(ProcessType processType, Point replicatePos, NodeType nodeTypeSource, String sourceName, INodeConnector nodeConnector, List<ConnectionType> connections, TalendFileFactory fileFact) {
NodeType nodeType = fileFact.createNodeType();
//$NON-NLS-1$
String uniqueName = ComponentUtilities.generateUniqueNodeName("tReplicate", processType);
ElementParameterType elemParam = fileFact.createElementParameterType();
//$NON-NLS-1$
elemParam.setField("TEXT");
//$NON-NLS-1$
elemParam.setName("UNIQUE_NAME");
elemParam.setValue(uniqueName);
nodeType.getElementParameter().add(elemParam);
ComponentUtilities.setNodeUniqueName(nodeType, uniqueName);
//$NON-NLS-1$
nodeType.setComponentName("tReplicate");
for (ConnectionType connectionType : connections) {
//$NON-NLS-1$
connectionType.setConnectorName("FLOW");
connectionType.setSource(uniqueName);
connectionType.setMetaname(uniqueName);
}
nodeType.setPosX(replicatePos.x);
nodeType.setPosY(replicatePos.y);
nodeType.setSizeX(GRID_SIZE);
nodeType.setSizeY(GRID_SIZE);
if (nodeTypeSource.getMetadata().size() != 0) {
MetadataType metadataTypeSource = null;
for (Object oMetadataType : nodeTypeSource.getMetadata()) {
MetadataType metadataType = (MetadataType) oMetadataType;
if ((metadataType.getConnector() != null && metadataType.getConnector().equals(nodeConnector.getName())) || metadataType.getName().equals(sourceName)) {
metadataTypeSource = metadataType;
}
}
if (metadataTypeSource != null) {
MetadataType newMetadataType = fileFact.createMetadataType();
newMetadataType.setComment(metadataTypeSource.getComment());
//$NON-NLS-1$
newMetadataType.setConnector("FLOW");
newMetadataType.setName(uniqueName);
for (Object oColumn : metadataTypeSource.getColumn()) {
ColumnType columnType = (ColumnType) oColumn;
ColumnType newColumnType = fileFact.createColumnType();
newColumnType.setComment(columnType.getComment());
newColumnType.setDefaultValue(columnType.getDefaultValue());
if (columnType.isSetKey()) {
newColumnType.setKey(columnType.isKey());
}
if (columnType.isSetLength()) {
newColumnType.setLength(columnType.getLength());
}
newColumnType.setName(columnType.getName());
if (columnType.isSetNullable()) {
newColumnType.setNullable(columnType.isNullable());
}
newColumnType.setOriginalDbColumnName(columnType.getOriginalDbColumnName());
newColumnType.setPattern(columnType.getPattern());
if (columnType.isSetPrecision()) {
newColumnType.setPrecision(columnType.getPrecision());
}
newColumnType.setSourceType(columnType.getSourceType());
newColumnType.setType(columnType.getType());
newMetadataType.getColumn().add(newColumnType);
}
nodeType.getMetadata().add(newMetadataType);
}
}
processType.getNode().add(nodeType);
return uniqueName;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class ReplaceMultiFlowBytReplicateMigrationTask method findLocationForNode.
/**
* DOC nrousseau Comment method "findLocationForNode".
*
* @param processType
* @param point
* @return
*/
private Point findLocationForNode(ProcessType processType, Point point) {
Rectangle newRect = new Rectangle(point, new Dimension(GRID_SIZE, GRID_SIZE));
Point newLocation = new Point(point);
for (Object oNodeType : processType.getNode()) {
NodeType node = (NodeType) oNodeType;
String uniqueName = ComponentUtilities.getNodeUniqueName(node);
Rectangle currentRect = getNodeRectangle(processType, uniqueName);
if (currentRect.intersects(newRect)) {
newLocation.x += GRID_SIZE;
newLocation.y += GRID_SIZE;
return findLocationForNode(processType, point);
}
}
return newLocation;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class SetUrltStewardshipXXXTDI32354 method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tStewardshipTaskInput", "tStewardshipTaskOutput", "tStewardshipTaskDelete" };
IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType host = ComponentUtilities.getNodeProperty(node, "HOST");
ElementParameterType port = ComponentUtilities.getNodeProperty(node, "PORT");
String url = "";
if (host != null && port != null) {
if ("tStewardshipTaskOutput".equals(node.getComponentName())) {
url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/dsctaskloader\"";
} else {
url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/TDSCWS?wsdl\"";
}
}
ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
if (serverVersion == null) {
ComponentUtilities.addNodeProperty(node, "URL", "TEXT");
serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
serverVersion.setValue(url);
}
}
};
for (String name : componentsName) {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
} 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 SettingValuesIntoHadoopPropertiesFortHiveConnection method execute.
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
try {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter("tELTHiveMap");
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$ //$NON-NLS-2$
ElementParameterType useExistingConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
if (useExistingConn != null && "true".equalsIgnoreCase(useExistingConn.getValue())) {
//$NON-NLS-1$
ElementParameterType connNamePara = ComponentUtilities.getNodeProperty(node, "CONNECTION");
if (connNamePara != null) {
NodeType tHiveConnNode = searchNodeTypeByUniqName(processType, connNamePara.getValue());
moveValuesFromHiveMap2HiveConn(node, tHiveConnNode);
}
}
}
}));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class SetDefaultValue4tWriteJSONFieldGroupByOutput method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tWriteJSONField");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
EList<ElementValueType> list = ComponentUtilities.getNodeProperty(node, "GROUPBYS").getElementValue();
ElementValueType outputColumnPropertyElement = null;
int size = list.size();
if (list != null && size > 0) {
String outputFieldValue = ComponentUtilities.getNodeProperty(node, "JSONFIELD").getValue();
for (int i = 0, j = 0; i < size; i++) {
outputColumnPropertyElement = TalendFileFactory.eINSTANCE.createElementValueType();
//$NON-NLS-1$
outputColumnPropertyElement.setElementRef("OUTPUT_COLUMN");
outputColumnPropertyElement.setValue(outputFieldValue);
list.add(j, outputColumnPropertyElement);
j = j + 2;
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations