use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class MultiSchemasUI method getFieldSeparatorStyleSupportByLanguage.
private String[] getFieldSeparatorStyleSupportByLanguage() {
ECodeLanguage language = LanguageManager.getCurrentLanguage();
String[] styles = { FieldSeparator.SEMICOLON_LITERAL.getName(), FieldSeparator.COMMA_LITERAL.getName(), FieldSeparator.TABULATION_LITERAL.getName(), FieldSeparator.SPACE_LITERAL.getName(), FieldSeparator.ALT_65_LITERAL.getName(), FieldSeparator.CUSTOM_ANSI_LITERAL.getName(), FieldSeparator.CUSTOM_UTF8_LITERAL.getName(), FieldSeparator.CUSTOM_REG_EXP_LITERAL.getName() };
switch(language) {
case JAVA:
String[] javaStyles = new String[styles.length - 1];
System.arraycopy(styles, 0, javaStyles, 0, javaStyles.length);
return javaStyles;
default:
// PERL
return styles;
}
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class AbstractHL7MetadataTableEditorView method configureTalendTypeColumn.
/**
* DOC amaumont Comment method "initTalendTypeColumn".
*
* @param tableViewerCreator
* @param comboValueAdapter
* @param arrayTalendTypes
*/
private TableViewerCreatorColumn configureTalendTypeColumn(final TableViewerCreator<B> tableViewerCreator) {
CellEditorValueAdapter comboValueAdapter = null;
ECodeLanguage codeLanguage = LanguageManager.getCurrentLanguage();
if (codeLanguage == ECodeLanguage.JAVA) {
comboValueAdapter = new JavaTypeComboValueAdapter<B>(JavaTypesManager.getDefaultJavaType(), getNullableAccessor());
} else if (codeLanguage == ECodeLanguage.PERL) {
comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor();
}
String[] arrayTalendTypes = new String[0];
try {
arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
} catch (NoClassDefFoundError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (ExceptionInInitializerError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
}
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("MetadataTableEditorView.TypleTitle"));
//$NON-NLS-1$
column.setToolTipHeader(Messages.getString("MetadataTableEditorView.TypleTitle"));
column.setId(ID_COLUMN_TYPE);
column.setBeanPropertyAccessors(getTalendTypeAccessor());
column.setModifiable(!isReadOnly());
column.setWeight(10);
column.setMinimumWidth(30);
ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
CCombo typeCombo = (CCombo) typeComboEditor.getControl();
typeCombo.setEditable(false);
column.setCellEditor(typeComboEditor, comboValueAdapter);
return column;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class ScdManager method createOutputSchema.
/**
* DOC chuang Comment method "createOutputSchema".
*
* @param unusedFields
*/
public void createOutputSchema() {
// adding the surrogate Keys column
Map<String, IMetadataColumn> surrogateKeysColumnMap = new HashMap<String, IMetadataColumn>();
List<IMetadataColumn> outputColumnsAll = getOutputColumns(component);
for (IMetadataColumn column : outputColumnsAll) {
if (column.isKey()) {
surrogateKeysColumnMap.put(column.getLabel(), column);
break;
}
}
// the unused columns must not be present in the output schema and also
// remove all generated column from
// output schema
Map<String, IMetadataColumn> outputColumns = removeUnusedAndGeneratedColumns(component.getMetadataList(), unusedFields);
IMetadataTable schema = component.getMetadataList().get(0);
// adding all used columns to output schema
Map<String, IMetadataColumn> inputColumnsMap = new HashMap<String, IMetadataColumn>();
List<IMetadataColumn> inputColumns = getInputColumns(component);
for (IMetadataColumn column : inputColumns) {
inputColumnsMap.put(column.getLabel(), column);
if (!unusedFields.contains(column.getLabel()) && outputColumns.get(column.getLabel()) == null) {
schema.getListColumns().add(cloneColumn(column, column.getLabel()));
}
}
// "current value" column
if (type3Table != null) {
for (Type3Field type3 : type3Table) {
if (outputColumns.get(type3.getPreviousValue()) != null || StringUtils.isEmpty(type3.getPreviousValue())) {
continue;
}
IMetadataColumn column = inputColumnsMap.get(type3.getCurrentValue());
IMetadataColumn previous = cloneColumn(column, type3.getPreviousValue());
outputColumns.put(previous.getLabel(), previous);
schema.getListColumns().add(previous);
}
}
// removeVersionFieldsFromOutput(outputColumns, schema, new String[] {
// versionData.getStartName(),
// versionData.getEndName(),
// versionData.getVersionName(), versionData.getActiveName() });
// for versionning columns {start, end} are datetime data type, version
// is an integer, active is a
// boolean
ECodeLanguage lang = LanguageManager.getCurrentLanguage();
if (type2Table != null && !type2Table.isEmpty()) {
// start date
IMetadataColumn startColumn = createMetadataColumn(outputColumns, schema, versionData.getStartName(), Date.class, lang);
if (startColumn != null) {
startColumn.setCustomId(1);
startColumn.setCustom(true);
}
// end date
IMetadataColumn endColumn = createMetadataColumn(outputColumns, schema, versionData.getEndName(), Date.class, lang);
if (endColumn != null) {
endColumn.setNullable(true);
endColumn.setCustomId(2);
endColumn.setCustom(true);
}
if (versionData.isVersionChecked()) {
IMetadataColumn versionColumn = createMetadataColumn(outputColumns, schema, versionData.getVersionName(), Integer.class, lang);
if (versionColumn != null) {
versionColumn.setCustomId(3);
versionColumn.setCustom(true);
}
}
if (versionData.isActiveChecked()) {
IMetadataColumn activeColumn = createMetadataColumn(outputColumns, schema, versionData.getActiveName(), Boolean.class, lang);
if (activeColumn != null) {
activeColumn.setCustomId(4);
activeColumn.setCustom(true);
}
}
}
fixKeyColumnsInOutputSchema(schema, inputColumnsMap, surrogateKeysColumnMap, lang);
// removed by TDI-30934
// sort column by name
// Collections.sort(schema.getListColumns(), new Comparator<IMetadataColumn>() {
//
// public int compare(IMetadataColumn o1, IMetadataColumn o2) {
//
// return o1.getLabel().compareTo(o2.getLabel());
// }
//
// });
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class ImportItemUtil method getRoutineSynchronizer.
// private void applyMigrationTasks(ItemRecord itemRecord, IProgressMonitor monitor) {
// Context ctx = CorePlugin.getContext();
// RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
// ITalendSynchronizer routineSynchronizer = getRoutineSynchronizer();
//
// ERepositoryObjectType repositoryType = itemRecord.getRepositoryType();
//
// Item item = null;
// try {
// List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(
// ProjectManager.getInstance().getCurrentProject(), itemRecord.getItemId(), itemRecord.getImportPath(),
// repositoryType);
// for (IRepositoryViewObject repositoryObject : allVersion) {
// if (repositoryObject.getProperty().getVersion().equals(itemRecord.getItemVersion())) {
// item = repositoryObject.getProperty().getItem();
// }
// }
// } catch (Exception e) {
// logError(e);
// }
//
// if (item == null) {
// return;
// }
//
// List<IProjectMigrationTask> toExecute = new ArrayList<IProjectMigrationTask>();
// for (String taskId : itemRecord.getMigrationTasksToApply()) {
// IProjectMigrationTask task = GetTasksHelper.getInstance().getProjectTask(taskId);
// if (task == null) {
// log.warn(Messages.getString("ImportItemUtil.taskLogWarn", taskId)); //$NON-NLS-1$
// } else if (!task.isDeprecated()) {
// toExecute.add(task);
// }
//
// }
// Collections.sort(toExecute, new Comparator<IProjectMigrationTask>() {
//
// public int compare(IProjectMigrationTask o1, IProjectMigrationTask o2) {
// return o1.getOrder().compareTo(o2.getOrder());
// }
// });
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// for (IProjectMigrationTask task : toExecute) {
// monitor.subTask(Messages.getString("ImportItemUtil.taskMonitor", task.getName(), itemRecord.getItemName())); //$NON-NLS-1$
// try {
// // in case the resource has been modified (see MergeTosMetadataMigrationTask for example)
// if ((item.getProperty().eResource() == null || item.eResource() == null)) {
// Property updatedProperty = factory.reload(item.getProperty());
// item = updatedProperty.getItem();
// }
//
// if (item != null) {
// ExecutionResult executionResult = task.execute(repositoryContext.getProject(), item);
// if (executionResult == ExecutionResult.FAILURE) {
// log.warn(Messages.getString("ImportItemUtil.itemLogWarn", itemRecord.getItemName(), task.getName())); //$NON-NLS-1$
// // TODO smallet add a warning/error to the job using
// // model
// }
// }
// } catch (Exception e) {
// log.warn(Messages.getString("ImportItemUtil.itemLogException", itemRecord.getItemName(), task.getName()), e); //$NON-NLS-1$
// try {
// factory.deleteObjectPhysical(new RepositoryObject(item.getProperty()));
// break;// stop migrating the object it has be deleted
// } catch (PersistenceException e1) {
// log.error("Could not delete physical item(" + item.getProperty().getLabel() + "), Project may be corrupted.",
// e);
// }
// }
// }
//
// try {
// if (item != null && item instanceof RoutineItem) {
// RoutineUtils.changeRoutinesPackage(item);
// RoutineItem routineItem = (RoutineItem) item;
// routineSynchronizer.forceSyncRoutine(routineItem);
// routineSynchronizer.syncRoutine(routineItem, true);
// routineSynchronizer.getFile(routineItem);
// }
// // if (item.getProperty().eResource().isModified()) {
// // ProxyRepositoryFactory.getInstance().save(item, true);
// // item.getProperty().eResource().setModified(false);
// // }
// if (item.getProperty().eResource() != null) {
// ProxyRepositoryFactory.getInstance().unloadResources(item.getProperty());
// if (item.getParent() != null && item.getParent() instanceof FolderItem) {
// ((FolderItem) item.getParent()).getChildren().remove(item);
// item.setParent(null);
// }
// }
//
// itemRecord.setExistingItemWithSameId(null);
// itemRecord.clear();
//
// } catch (Exception e) {
// logError(e);
// }
// }
private ITalendSynchronizer getRoutineSynchronizer() {
ICodeGeneratorService service = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
ITalendSynchronizer routineSynchronizer = null;
switch(lang) {
case JAVA:
routineSynchronizer = service.createJavaRoutineSynchronizer();
break;
case PERL:
routineSynchronizer = service.createPerlRoutineSynchronizer();
break;
default:
//$NON-NLS-1$
throw new UnsupportedOperationException(Messages.getString("ImportItemUtil.unknowException", lang));
}
return routineSynchronizer;
}
use of org.talend.core.language.ECodeLanguage in project tdi-studio-se by Talend.
the class ImplicitContextLoadHelper method saveValuesToPreferencePage.
/**
* DOC hcw Comment method "saveValuesToPreferencePage".
*
* @param elem
* @param extraComposite
*/
public static void saveValuesToPreferencePage(Element element, ExtraComposite extraComposite) {
ECodeLanguage language = LanguageManager.getCurrentLanguage();
//$NON-NLS-1$
String languagePrefix = language.toString() + "_";
EParameterName[] params = { EParameterName.IMPLICIT_TCONTEXTLOAD, EParameterName.FROM_FILE_FLAG, EParameterName.FROM_DATABASE_FLAG, EParameterName.IMPLICIT_TCONTEXTLOAD_FILE, EParameterName.FIELDSEPARATOR, EParameterName.DB_TYPE, EParameterName.HOST, EParameterName.PORT, EParameterName.DBNAME, EParameterName.SCHEMA_DB, EParameterName.USER, EParameterName.PASS, EParameterName.DBFILE, EParameterName.DBTABLE, EParameterName.QUERY_CONDITION, EParameterName.LOAD_NEW_VARIABLE, EParameterName.NOT_LOAD_OLD_VARIABLE, EParameterName.PRINT_OPERATIONS, EParameterName.DISABLE_WARNINGS, EParameterName.DISABLE_ERROR, EParameterName.DISABLE_INFO };
Map<String, EParameterName> extraParams = new HashMap<String, EParameterName>();
for (EParameterName param : params) {
extraParams.put(getExtraParameterName(param), param);
}
List<? extends IElementParameter> elementParameters = element.getElementParameters();
for (IElementParameter elementParameter : elementParameters) {
String name = elementParameter.getName();
Object value = elementParameter.getValue();
if (name.equals(getExtraParameterName(EParameterName.PROPERTY_TYPE))) {
savePropertyTypeToPreference(extraComposite, languagePrefix, elementParameter);
} else if (extraParams.containsKey(name)) {
if (value instanceof String) {
PREFERENCE_STORE.setValue(languagePrefix + getExtraParameterName(extraParams.get(name)), removeQuote((String) value));
} else if (value instanceof Boolean) {
PREFERENCE_STORE.setValue(languagePrefix + getExtraParameterName(extraParams.get(name)), (Boolean) value);
}
}
}
}
Aggregations