use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4ProjectSettingsMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
*/
@Override
public ExecutionResult execute(Project project) {
org.talend.core.model.properties.Project emfProject = project.getEmfProject();
StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
boolean modified = false;
if (statAndLogs != null && statAndLogs.getParameters() != null) {
ParametersType parameters = statAndLogs.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterType) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for Stat&Logs
if ("PASS".equals(name)) {
//$NON-NLS-1$
parameterType.setField(EParameterFieldType.PASSWORD.getName());
try {
if (reencryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
if (implicitContext != null && implicitContext.getParameters() != null) {
ParametersType parameters = implicitContext.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for implicit context
if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-1$
parameterType.setField(EParameterFieldType.PASSWORD.getName());
try {
if (reencryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
if (modified) {
try {
factory.saveProject(project);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class UnifyParameterOfDatastaxAndHectorForCassandra method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String[] compNames = { "tCassandraInput", "tCassandraOutput", "tCassandraRow", "tCassandraLookupInput" };
IComponentConversion conversion = new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType cf = ComponentUtilities.getNodeProperty(node, "TABLE");
if (cf != null) {
if (ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "COLUMN_FAMILY", "TEXT");
}
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY").setValue(cf.getValue());
}
//$NON-NLS-1$
ElementParameterType actionForCF = ComponentUtilities.getNodeProperty(node, "TABLE_ACTION");
if (actionForCF != null) {
if (ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "ACTION_ON_COLUMN_FAMILY", "TEXT");
}
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "ACTION_ON_COLUMN_FAMILY").setValue(actionForCF.getValue());
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
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 UpdateCheckResult method getCategory.
@Override
@SuppressWarnings("unchecked")
public String getCategory() {
String category = null;
if (getUpdateType() instanceof EUpdateItemType) {
switch((EUpdateItemType) getUpdateType()) {
case NODE_PROPERTY:
case NODE_SCHEMA:
case NODE_QUERY:
case NODE_VALIDATION_RULE:
case JOBLET_SCHEMA:
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof Node) {
Node node = (Node) getUpdateObject();
if (node.getUniqueName().equals(node.getLabel())) {
category = node.getUniqueName();
} else {
category = node.getLabel() + UpdateManagerUtils.addBrackets(node.getUniqueName());
}
}
if (getUpdateObject() instanceof NodeType) {
NodeType node = (NodeType) getUpdateObject();
String uniqueName = null;
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
if (EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
uniqueName = param.getValue();
break;
}
}
if (uniqueName != null) {
category = uniqueName;
}
}
}
break;
case JOB_PROPERTY_EXTRA:
case JOB_PROPERTY_STATS_LOGS:
case JOB_PROPERTY_HEADERFOOTER:
case JOB_PROPERTY_MAPREDUCE:
boolean isJoblet = false;
boolean isMR = false;
if (getUpdateObject() != null) {
if (getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (AbstractProcessProvider.isExtensionProcessForJoblet((IProcess) getUpdateObject())) {
isJoblet = true;
} else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isMR = mrProcessService.isMapReduceItem(item);
}
}
}
if (isMR) {
//
category = JobSettingsView.VIEW_NAME_BATCH;
} else if (isJoblet) {
// joblet
category = JobSettingsView.VIEW_NAME_JOBLET;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case JOB_PROPERTY_STORM:
boolean isStreaming = false;
if (getUpdateObject() != null && getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
isStreaming = streamingService.isStormItem(item);
}
}
if (isStreaming) {
//
category = JobSettingsView.VIEW_NAME_STREAMING;
} else {
category = JobSettingsView.getViewNameLable();
}
break;
case CONTEXT:
// case JOBLET_CONTEXT:
category = UpdatesConstants.CONTEXT;
break;
case CONTEXT_GROUP:
category = UpdatesConstants.CONTEXT_GROUP;
break;
case JOBLET_RENAMED:
case RELOAD:
case JUNIT_RELOAD:
if (getUpdateObject() != null && getUpdateObject() instanceof List) {
String display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), true);
if (display != null) {
category = display;
}
} else if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
// reload all compoennts.
if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
category = UpdatesConstants.COMPONENT;
break;
}
} else {
category = UpdatesConstants.JOBLET;
}
break;
default:
}
} else {
category = UpdateManagerProviderDetector.INSTANCE.getDisplayCategory(this);
}
return category == null ? UpdatesConstants.EMPTY : category;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class JobletUtil method isJobletInput.
public boolean isJobletInput(Node connNode, IProcess2 process) {
if (process.getProperty().getItem() instanceof JobletProcessItem) {
JobletProcess jobletProcess = ((JobletProcessItem) process.getProperty().getItem()).getJobletProcess();
List<JobletNode> jobletNodes = jobletProcess.getJobletNodes();
for (JobletNode jnode : jobletNodes) {
List list = jnode.getElementParameter();
for (Object obj : list) {
if (obj instanceof ElementParameterType) {
if (((ElementParameterType) obj).getValue().equals(connNode.getJoblet_unique_name())) {
return jnode.isInput();
}
}
}
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class UpgradeParameterHelper method upgradeRelatedParameters.
/**
*
* ggu Comment method "upgradeRelatedParameters".
*
* "type =null" is only for property type parameter.
*/
private static boolean upgradeRelatedParameters(ElementParameterType repositoryParam, String repositoryParamName, final String oleTypeParamName, String newTypeParamName, final String parentName, List<ElementParameterType> elemParamList, ERepositoryObjectType type) {
if (repositoryParam == null || oleTypeParamName == null || parentName == null || elemParamList == null || elemParamList.isEmpty()) {
return false;
}
if (repositoryParamName == null) {
repositoryParamName = repositoryParam.getName();
}
if (newTypeParamName == null) {
newTypeParamName = oleTypeParamName;
}
// related paramter
// such as PROPERTY_TYPE, QUERYSTORE_TYPE, SCHEMA_TYPE
ElementParameterType typeParam = findParameter(oleTypeParamName, elemParamList);
if (typeParam != null) {
repositoryParam.setName(parentName + COLON + repositoryParamName);
repositoryParam.setField(EParameterFieldType.TECHNICAL.getName());
typeParam.setName(parentName + COLON + newTypeParamName);
typeParam.setField(EParameterFieldType.TECHNICAL.getName());
// update the value
updateParameterValue(repositoryParam, typeParam, parentName, type);
return true;
}
return false;
}
Aggregations