use of org.talend.core.model.metadata.types.JavaType in project tdi-studio-se by Talend.
the class AddSchemaDefaultValue4tFileInputDelimited method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tFileInputDelimited");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
EList<EObject> list = node.eContents();
for (EObject object : list) {
if (object instanceof MetadataType) {
MetadataType flow = (MetadataType) object;
if ("FLOW".equalsIgnoreCase(flow.getConnector())) {
Iterator<?> columns = flow.getColumn().iterator();
while (columns.hasNext()) {
Object outColumn = columns.next();
if (outColumn instanceof ColumnType) {
ColumnType column = ((ColumnType) outColumn);
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getType());
boolean isJavaPrimitiveType = JavaTypesManager.isJavaPrimitiveType(javaType, column.isNullable());
if (isJavaPrimitiveType && (column.getDefaultValue() == null || column.getDefaultValue().isEmpty())) {
String defaultValue = JavaTypesManager.getDefaultValueFromJavaType(javaType.getPrimitiveClass().getSimpleName(), null);
if (defaultValue != null) {
column.setDefaultValue(defaultValue);
}
}
}
}
}
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.core.model.metadata.types.JavaType in project tdi-studio-se by Talend.
the class MetadataTypeLengthPreferencePage method createJavaFieldEditors.
/**
* DOC qwei Comment method "createJavaFieldEditors".
*/
private void createJavaFieldEditors(Composite com) {
JavaType[] strTypeValue = JavaTypesManager.getJavaTypes();
String[] strDisplay = new String[strTypeValue.length];
String[] strValue = new String[strTypeValue.length];
for (int i = 0; i < strDisplay.length; i++) {
strDisplay[i] = strTypeValue[i].getNullableClass().getSimpleName();
strValue[i] = strTypeValue[i].getId();
}
String[][] strvalueType = new String[strDisplay.length][2];
for (int i = 0; i < strDisplay.length; i++) {
strvalueType[i][0] = strDisplay[i];
strvalueType[i][1] = strValue[i];
}
comboValueTypeField = new ComboFieldEditor(MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE, Messages.getString("MetadataTypeLengthConstants.VALUE_DEFAULT_TYPE"), strvalueType, //$NON-NLS-1$
com);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
com.setLayoutData(gridData);
GridLayout gridLayout = (GridLayout) com.getLayout();
gridLayout.numColumns = 6;
com.setLayout(gridLayout);
valueLengthField = new StringFieldEditor(MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH, Messages.getString("MetadataTypeLengthConstants.VALUE_DEFAULT_LENGTH"), //$NON-NLS-1$
valueGroup);
addField(comboValueTypeField);
addField(valueLengthField);
/**
* set Fields
*
*/
fieldGroup = new Group(parent, SWT.NONE);
//$NON-NLS-1$
fieldGroup.setText(Messages.getString("MetadataTypeLengthPreferencePage.FIELD"));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
fieldGroup.setLayoutData(gd);
com = new Composite(fieldGroup, SWT.NONE);
comboFieldTypeField = new ComboFieldEditor(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE, Messages.getString("MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE"), strvalueType, //$NON-NLS-1$
com);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
com.setLayoutData(gridData);
gridLayout = (GridLayout) com.getLayout();
gridLayout.numColumns = 6;
com.setLayout(gridLayout);
fieldLengthField = new StringFieldEditor(MetadataTypeLengthConstants.FIELD_DEFAULT_LENGTH, Messages.getString("MetadataTypeLengthConstants.FIELD_DEFAULT_LENGTH"), //$NON-NLS-1$
fieldGroup);
/**
* set data Type
*/
dbTypeGroup = new Group(parent, SWT.NONE);
//$NON-NLS-1$
dbTypeGroup.setText(Messages.getString("MetadataTypeLengthPreferencePage.DBTYPE"));
gd = new GridData(GridData.FILL_HORIZONTAL);
dbTypeGroup.setLayoutData(gd);
booleanField = new StringFieldEditor(MetadataTypeLengthConstants.ID_BOOLEAN, Messages.getString("MetadataTypeLengthConstants.BOOLEAN_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
bigDecimalField = new StringFieldEditor(MetadataTypeLengthConstants.ID_BIGDECIMAL, Messages.getString("MetadataTypeLengthConstants.BIGDECIMAL_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
byteField = new StringFieldEditor(MetadataTypeLengthConstants.ID_BYTE, Messages.getString("MetadataTypeLengthConstants.BYTE_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
integerField = new StringFieldEditor(MetadataTypeLengthConstants.ID_INTEGER, Messages.getString("MetadataTypeLengthConstants.INTEGER_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
bytearrayField = new StringFieldEditor(MetadataTypeLengthConstants.ID_BYTEARRAY, Messages.getString("MetadataTypeLengthConstants.BYTEARRAY_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
longField = new StringFieldEditor(MetadataTypeLengthConstants.ID_LONG, Messages.getString("MetadataTypeLengthConstants.LONG_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
characterField = new StringFieldEditor(MetadataTypeLengthConstants.ID_CHARACTER, Messages.getString("MetadataTypeLengthConstants.CHARACTER_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
objectField = new StringFieldEditor(MetadataTypeLengthConstants.ID_OBJECT, Messages.getString("MetadataTypeLengthConstants.OBJECT_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
dateField = new StringFieldEditor(MetadataTypeLengthConstants.ID_DATE, Messages.getString("MetadataTypeLengthConstants.DATE_LENGHT"), //$NON-NLS-1$
dbTypeGroup);
shortField = new StringFieldEditor(MetadataTypeLengthConstants.ID_SHORT, Messages.getString("MetadataTypeLengthConstants.SHORT_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
doubleField = new StringFieldEditor(MetadataTypeLengthConstants.ID_DOUBLE, Messages.getString("MetadataTypeLengthConstants.DOUBLE_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
stringField = new StringFieldEditor(MetadataTypeLengthConstants.ID_STRING, Messages.getString("MetadataTypeLengthConstants.STRING_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
floatField = new StringFieldEditor(MetadataTypeLengthConstants.ID_FLOAT, Messages.getString("MetadataTypeLengthConstants.FLOAT_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
listField = new StringFieldEditor(MetadataTypeLengthConstants.ID_LIST, Messages.getString("MetadataTypeLengthConstants.LIST_LENGTH"), //$NON-NLS-1$
dbTypeGroup);
addField(comboFieldTypeField);
addField(fieldLengthField);
gridLayout = (GridLayout) dbTypeGroup.getLayout();
gridLayout.numColumns = 4;
dbTypeGroup.setLayout(gridLayout);
addField(bigDecimalField);
addField(booleanField);
addField(byteField);
addField(integerField);
addField(bytearrayField);
addField(longField);
addField(characterField);
addField(objectField);
addField(dateField);
addField(shortField);
addField(doubleField);
addField(stringField);
addField(floatField);
addField(listField);
}
use of org.talend.core.model.metadata.types.JavaType in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method getTypeDisplayValue.
private String getTypeDisplayValue(VarNode varNode) {
JavaType javaType = JavaTypesManager.getJavaTypeFromId(varNode.getType());
Class primitiveClass = javaType.getPrimitiveClass();
Boolean nullable = varNode.isNullable();
String displayedValue = null;
if (primitiveClass != null && !nullable.equals(Boolean.TRUE)) {
displayedValue = primitiveClass.getSimpleName();
} else if (varNode.getType().equals(JavaTypesManager.DIRECTORY.getId()) || varNode.getType().equals(JavaTypesManager.FILE.getId()) || varNode.getType().equals(JavaTypesManager.VALUE_LIST.getId())) {
displayedValue = javaType.getLabel();
} else {
displayedValue = javaType.getNullableClass().getSimpleName();
}
if (displayedValue == null) {
displayedValue = JavaTypesManager.getDefaultJavaType().getLabel();
}
return displayedValue;
}
use of org.talend.core.model.metadata.types.JavaType in project tdi-studio-se by Talend.
the class VarEntityFigure method getTypeDisplayValue.
private String getTypeDisplayValue(String type, boolean nullable) {
JavaType javaType = JavaTypesManager.getJavaTypeFromId(type);
Class primitiveClass = javaType.getPrimitiveClass();
String displayedValue = null;
if (primitiveClass != null && !Boolean.TRUE.equals(nullable)) {
displayedValue = primitiveClass.getSimpleName();
} else if (type.equals(JavaTypesManager.DIRECTORY.getId()) || type.equals(JavaTypesManager.FILE.getId()) || type.equals(JavaTypesManager.VALUE_LIST.getId())) {
displayedValue = javaType.getLabel();
} else {
displayedValue = javaType.getNullableClass().getSimpleName();
}
if (displayedValue == null) {
displayedValue = JavaTypesManager.getDefaultJavaType().getLabel();
}
return displayedValue;
}
use of org.talend.core.model.metadata.types.JavaType in project tdi-studio-se by Talend.
the class ContextParameterPage method getJavaDisplayedType.
private String getJavaDisplayedType(String originalTypedValue) {
JavaType javaType;
javaType = ContextParameterJavaTypeManager.getJavaTypeFromLabel(originalTypedValue);
String type;
if (javaType == null) {
type = MetadataTalendType.getDefaultTalendType();
} else {
type = javaType.getId();
}
return type;
}
Aggregations