use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class ExportProcessorHelper method exportJob.
public String exportJob(Processor processor, int statisticsPort, int tracePort, String watchParam, String log4jLevel, final IProgressMonitor progressMonitor) throws ProcessorException {
ProcessItem processItem = (ProcessItem) processor.getProperty().getItem();
processName = processor.getProperty().getLabel();
//$NON-NLS-1$
File archiveFile = new File(getTmpExportFolder(), "remote_run_export-" + processName + FileExtensions.ZIP_FILE_SUFFIX);
Properties prop = new Properties();
if (watchParam != null) {
prop.setProperty(TalendProcessArgumentConstant.ARG_ENABLE_WATCH, watchParam);
}
// FIXME, maybe should try another way. it's not good, I think.
// update directly the .item (without save it) in case of prompt
// then the generation will be correct automatically in the .properties
IContext context = processor.getContext();
if (context != null) {
List<IContextParameter> contextParameterList = context.getContextParameterList();
if (contextParameterList != null && contextParameterList.size() > 0) {
for (IContextParameter contextParameter : contextParameterList) {
if (!contextParameter.isPromptNeeded()) {
continue;
}
for (Object curCType : processItem.getProcess().getContext()) {
ContextType cType = (ContextType) curCType;
if (context.getName().equals(cType.getName())) {
for (Object curParam : cType.getContextParameter()) {
ContextParameterType cParamType = (ContextParameterType) curParam;
if (contextParameter.getName().equals(cParamType.getName())) {
cParamType.setRawValue(contextParameter.getValue());
}
}
}
}
}
}
}
export(progressMonitor, processItem, ERepositoryObjectType.getItemType(processItem), processor.getContext().getName(), archiveFile.toString(), log4jLevel, false, statisticsPort, tracePort, prop);
return archiveFile.toString();
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class EncryptDbPasswordMigrationTask method encryptContextPassword.
/**
* DOC chuang Comment method "encryptContextPassword".
*
* @param item
* @param contextTypeList
* @return
*/
private ExecutionResult encryptContextPassword(Item item, List<ContextType> contextTypeList) {
boolean modify = false;
if (contextTypeList != null) {
for (ContextType type : contextTypeList) {
List<ContextParameterType> paramTypes = type.getContextParameter();
if (paramTypes != null) {
for (ContextParameterType param : paramTypes) {
try {
// before migration task, the value should be raw. so keep it.
if (param.getValue() != null && PasswordEncryptUtil.isPasswordType(param.getType())) {
encryptPassword(param);
modify = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
if (modify) {
try {
factory.save(item, 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.ContextParameterType in project tdi-studio-se by Talend.
the class ExportJobUtil method getJobContextValues.
/**
* DOC zli Comment method "getJobContextValues".
*
* @param processItem
* @param contextName
* @return
*/
@SuppressWarnings("rawtypes")
public static List<ContextParameterType> getJobContextValues(ProcessItem processItem, String contextName) {
if (contextName == null) {
return null;
}
// else do next line
List<ContextParameterType> list = new ArrayList<ContextParameterType>();
EList contexts = ((ProcessTypeImpl) processItem.getProcess()).getContext();
for (int i = 0; i < contexts.size(); i++) {
Object object = contexts.get(i);
if (object instanceof ContextType) {
ContextType contextType = (ContextType) object;
if (contextName.equals(contextType.getName())) {
EList contextParameter = contextType.getContextParameter();
for (int j = 0; j < contextParameter.size(); j++) {
Object object2 = contextParameter.get(j);
if (object2 instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) object2;
list.add(contextParameterType);
}
}
return list;
}
}
}
return null;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class ReplaceJavaKeywordsNameForContextMigrationTask method getReplacedNamesAndReplaceContextVars.
/**
*
* ggu Comment method "getReplacedNamesAndReplaceContextVars".
*
* get the replaced names, and replace the context variables at the same time.
*/
@SuppressWarnings("unchecked")
private Map<String, Map<String, String>> getReplacedNamesAndReplaceContextVars() {
// id to map(oldName to newName)
Map<String, Map<String, String>> contextIdNamesMap = new HashMap<String, Map<String, String>>();
List<ContextItem> allContextItem = ContextUtils.getAllContextItem();
if (allContextItem != null) {
for (ContextItem contextItem : allContextItem) {
boolean changed = false;
boolean first = true;
Set<String> varNames = null;
for (ContextType contextType : (List<ContextType>) contextItem.getContext()) {
if (first) {
varNames = ContextUtils.getContextVarNames(contextType);
}
// oldName to newName
Map<String, String> nameMap = new HashMap<String, String>();
final String contextId = contextItem.getProperty().getId();
for (ContextParameterType paramType : (List<ContextParameterType>) contextType.getContextParameter()) {
String oldName = paramType.getName();
if (first) {
if (ContextUtils.isJavaKeyWords(oldName)) {
// is java keywords
String newName = getNewName(varNames, oldName);
nameMap.put(newName, oldName);
paramType.setName(newName);
changed = true;
}
} else {
String newName = getContextNewNameFromMap(contextIdNamesMap, contextId, oldName);
if (newName != null) {
// is java keywords
paramType.setName(newName);
changed = true;
}
}
}
if (first && !nameMap.isEmpty()) {
contextIdNamesMap.put(contextId, nameMap);
}
first = false;
}
if (changed) {
// save
try {
factory.save(contextItem, true);
} catch (PersistenceException e) {
//
}
}
}
}
return contextIdNamesMap;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class ReplaceJavaKeywordsNameForContextMigrationTask method modifyJobContext.
/**
*
* ggu Comment method "modifyJobContext".
*
* this function will get the replaced variables map.
*/
@SuppressWarnings("unchecked")
private boolean modifyJobContext(Map<String, String> jobContextReplacedNamesMap, List<ContextType> contextTypeList) {
if (contextTypeList == null || contextTypeList.isEmpty()) {
return false;
}
boolean changed = false;
boolean first = true;
Set<String> varNames = null;
for (ContextType contextType : (List<ContextType>) contextTypeList) {
if (first) {
varNames = ContextUtils.getContextVarNames(contextType);
}
for (ContextParameterType paramType : (List<ContextParameterType>) contextType.getContextParameter()) {
final String oldName = paramType.getName();
final String sourceId = paramType.getRepositoryContextId();
if (first) {
if (ContextUtils.isJavaKeyWords(oldName)) {
// is java keywords
String newName = getNewName(varNames, oldName);
String tmpName = getContextNewNameFromMap(contextReplacedNamesMap, sourceId, oldName);
if (tmpName != null) {
// from repository context
newName = tmpName;
}
jobContextReplacedNamesMap.put(newName, oldName);
paramType.setName(newName);
changed = true;
}
} else {
String newName = getJobContextNewNameFromMap(jobContextReplacedNamesMap, oldName);
if (newName != null) {
// is key words
paramType.setName(newName);
changed = true;
}
}
}
}
return changed;
}
Aggregations