use of org.talend.core.model.process.EComponentCategory in project tdi-studio-se by Talend.
the class JobSettingsView method getCategories.
/**
* set the category.
*/
private EComponentCategory[] getCategories(Object obj) {
List<EComponentCategory> category = new ArrayList<EComponentCategory>();
boolean isOfflineMode = CorePlugin.getDefault().getProxyRepositoryFactory().getRepositoryContext().isOffline();
if (obj instanceof Process) {
Process process = (Process) obj;
category.add(EComponentCategory.MAIN);
boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(process);
if (process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
category.add(EComponentCategory.EXTRA);
}
if (!isJoblet && process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
category.add(EComponentCategory.STATSANDLOGS);
}
if (allowVerchange) {
category.add(EComponentCategory.VERSIONS);
}
if (!isJoblet && !ProcessUtils.isTestContainer(process) && ERepositoryObjectType.getItemType(process.getProperty().getItem()) != ERepositoryObjectType.PROCESS_ROUTELET) {
category.add(EComponentCategory.DEPLOYMENT);
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHeaderFooterProviderService.class)) {
IHeaderFooterProviderService headerFooterService = (IHeaderFooterProviderService) GlobalServiceRegister.getDefault().getService(IHeaderFooterProviderService.class);
if (headerFooterService.isVisible()) {
category.add(EComponentCategory.HEADERFOOTER);
}
}
// if svn remote connection, added by nma
if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode) {
category.add(EComponentCategory.SVNHISTORY);
}
if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode) {
category.add(EComponentCategory.GITHISTORY);
}
} else if (obj instanceof IRepositoryViewObject) {
category.add(EComponentCategory.MAIN);
if (allowVerchange) {
category.add(EComponentCategory.VERSIONS);
}
if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
category.add(EComponentCategory.SVNHISTORY);
} else if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
category.add(EComponentCategory.GITHISTORY);
}
} else if (obj instanceof IEditorPart) {
if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
category.add(EComponentCategory.MAIN);
category.add(EComponentCategory.APPEARANCE);
category.add(EComponentCategory.RULERS_AND_GRID);
if (allowVerchange) {
category.add(EComponentCategory.VERSIONS);
}
}
} else {
BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
if (BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
category.add(EComponentCategory.APPEARANCE);
category.add(EComponentCategory.ASSIGNMENT);
} else if (BusinessType.NOTE.equals(type)) {
category.add(EComponentCategory.APPEARANCE);
}
}
return category.toArray(new EComponentCategory[0]);
}
use of org.talend.core.model.process.EComponentCategory in project tdi-studio-se by Talend.
the class JobSettingsView method setElement.
/**
*
* DOC ggu Comment method "setElement".
*
* @param obj
*/
private void setElement(Object obj, final String title, Image image) {
EComponentCategory[] categories = null;
if (obj != null && obj instanceof Process) {
process = (Process) obj;
if (currentSelectedTab != null && currentSelectedTab.getData().equals(process) && !cleaned) {
return;
}
categories = getCategories(process);
} else if (obj != null && obj instanceof IRepositoryViewObject) {
categories = getCategories(obj);
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
IProcess process = getProcess(viewObject);
if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
categories = getCategories(process);
}
} else if (obj instanceof IEditorPart) {
if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
categories = getCategories(obj);
}
} else {
BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
if (BusinessType.NOTE.equals(type) || BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
categories = getCategories(obj);
} else {
cleanDisplay();
return;
}
}
final List<TalendPropertyTabDescriptor> descriptors = new ArrayList<TalendPropertyTabDescriptor>();
for (EComponentCategory category : categories) {
TalendPropertyTabDescriptor d = new TalendPropertyTabDescriptor(category);
d.setData(obj);
descriptors.add(d);
}
tabFactory.setInput(descriptors);
setPartName(title, image);
cleaned = false;
tabFactory.setSelection(new IStructuredSelection() {
@Override
public Object getFirstElement() {
return null;
}
@Override
public Iterator iterator() {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public Object[] toArray() {
return null;
}
@Override
public List toList() {
List<TalendPropertyTabDescriptor> d = new ArrayList<TalendPropertyTabDescriptor>();
if (descriptors.size() > 0) {
if (currentSelectedTab != null) {
for (TalendPropertyTabDescriptor ds : descriptors) {
if (ds.getCategory() == currentSelectedTab.getCategory()) {
d.add(ds);
return d;
}
}
}
d.add(descriptors.get(0));
}
return d;
}
@Override
public boolean isEmpty() {
return false;
}
});
}
use of org.talend.core.model.process.EComponentCategory in project tdi-studio-se by Talend.
the class ComponentSettingsView method createButtonListener.
/**
* DOC zwang Comment method "createButtons".
*/
private void createButtonListener() {
// TODO Auto-generated method stub
// tabFactory.getTabbedPropertyComposite().getComposite().setBackground(
// ImageProvider.getImage(EImage.COMPOSITE_BACKGROUND).getBackground());
Button compactButton = tabFactory.getTabbedPropertyComposite().getCompactButton();
if (compactButton != null && !compactButton.isDisposed()) {
compactButton.setVisible(true);
if (compactListener == null) {
compactListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getPreference().setValue(TalendDesignerPrefConstants.VIEW_OPTIONS, ComponentSettingsView.DEFAULT);
if (getDc() != null) {
getDc().dispose();
Composite composite = getParentMap().get(ComponentSettingsView.PARENT);
EComponentCategory category2 = getCategoryMap().get(ComponentSettingsView.CATEGORY);
if (composite != null && category2 != null) {
createDynamicComposite(composite, element, category2);
}
}
}
};
compactButton.addSelectionListener(compactListener);
}
}
Button tableButton = tabFactory.getTabbedPropertyComposite().getTableButton();
if (tableButton != null && !tableButton.isDisposed()) {
tableButton.setVisible(true);
if (tableButtonListener == null) {
tableButtonListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getPreference().setValue(TalendDesignerPrefConstants.VIEW_OPTIONS, ComponentSettingsView.TABLEVIEW);
if (getDc() != null) {
getDc().dispose();
Composite composite = getParentMap().get(ComponentSettingsView.PARENT);
EComponentCategory category2 = getCategoryMap().get(ComponentSettingsView.CATEGORY);
if (composite != null && category2 != null) {
createDynamicComposite(composite, element, category2);
}
}
}
};
tableButton.addSelectionListener(tableButtonListener);
}
}
}
use of org.talend.core.model.process.EComponentCategory in project tdi-studio-se by Talend.
the class UpdateMainParameterCommand method execute.
@Override
public void execute() {
if (result == null) {
return;
}
Object job = result.getJob();
if (job == null) {
return;
}
if (job instanceof IProcess2) {
Process process = (Process) job;
EComponentCategory category = null;
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case JOB_PROPERTY_EXTRA:
category = EComponentCategory.EXTRA;
break;
case JOB_PROPERTY_STATS_LOGS:
category = EComponentCategory.STATSANDLOGS;
break;
case JOB_PROPERTY_HEADERFOOTER:
category = EComponentCategory.HEADERFOOTER;
break;
case JOB_PROPERTY_STORM:
if (ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
category = EComponentCategory.SPARK_JOB_CONFIG;
}
break;
case JOB_PROPERTY_MAPREDUCE:
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType())) {
category = EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP;
} else if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType())) {
category = EComponentCategory.SPARK_JOB_CONFIG;
}
break;
default:
}
if (category == EComponentCategory.HEADERFOOTER) {
if (result.getResultType() == EUpdateResult.UPDATE) {
if (result.isChecked()) {
for (IElementParameter param : process.getElementParameters()) {
if (param.getCategory() == EComponentCategory.HEADERFOOTER) {
IElementParameter headerIDParameter = process.getElementParameter(EParameterName.HEADERFOOTER_HEADERID.getName());
if (headerIDParameter != null) {
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById((String) headerIDParameter.getValue());
HeaderFooterConnection repositoryConnection = null;
if (lastVersion != null) {
final Item item = lastVersion.getProperty().getItem();
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = (HeaderFooterConnection) ((HeaderFooterConnectionItem) item).getConnection();
if (repositoryConnection != null) {
Boolean isHeader = repositoryConnection.isIsHeader();
String libraries = repositoryConnection.getLibraries();
String mainCode = repositoryConnection.getMainCode();
String imports = repositoryConnection.getImports();
process.getElementParameter(EParameterName.HEADER_ENABLED.getName()).setValue(isHeader);
process.getElementParameter(EParameterName.HEADER_LIBRARY.getName()).setValue(libraries);
process.getElementParameter(EParameterName.HEADER_CODE.getName()).setValue(mainCode);
process.getElementParameter(EParameterName.HEADER_IMPORT.getName()).setValue(imports);
}
}
}
}
IElementParameter footerIDParameter = process.getElementParameter(EParameterName.HEADERFOOTER_FOOTERID.getName());
if (footerIDParameter != null) {
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById((String) footerIDParameter.getValue());
HeaderFooterConnection repositoryConnection = null;
if (lastVersion != null) {
final Item item = lastVersion.getProperty().getItem();
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = (HeaderFooterConnection) ((HeaderFooterConnectionItem) item).getConnection();
if (repositoryConnection != null) {
Boolean isHeader = repositoryConnection.isIsHeader();
String libraries = repositoryConnection.getLibraries();
String mainCode = repositoryConnection.getMainCode();
String imports = repositoryConnection.getImports();
process.getElementParameter(EParameterName.FOOTER_ENABLED.getName()).setValue(!isHeader);
process.getElementParameter(EParameterName.FOOTER_LIBRARY.getName()).setValue(libraries);
process.getElementParameter(EParameterName.FOOTER_CODE.getName()).setValue(mainCode);
process.getElementParameter(EParameterName.FOOTER_IMPORT.getName()).setValue(imports);
}
}
}
}
}
}
}
}
} else if (category != null) {
boolean repository = false;
if (result.getResultType() == EUpdateResult.UPDATE) {
// upgrade from repository
if (result.isChecked()) {
IElementParameter property = process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
if (property != null) {
Map<String, IElementParameter> childParameters = property.getChildParameters();
if (childParameters != null) {
IElementParameter elementParameter = childParameters.get(EParameterName.PROPERTY_TYPE.getName());
// is repository
if (elementParameter != null && EmfComponent.REPOSITORY.equals(elementParameter.getValue())) {
for (IElementParameter param : process.getElementParameters()) {
if (param.getCategory() != category) {
continue;
}
String repositoryValue = param.getRepositoryValue();
if (param.isShow(process.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName()))) {
Object objectValue = RepositoryToComponentProperty.getValue((org.talend.core.model.metadata.builder.connection.Connection) result.getParameter(), repositoryValue, null);
if (objectValue != null) {
if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && repositoryValue.equals(UpdatesConstants.TYPE)) {
boolean found = false;
String[] items = param.getListRepositoryItems();
for (int i = 0; (i < items.length) && (!found); i++) {
if (objectValue.equals(items[i])) {
found = true;
process.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
}
}
} else if (EParameterName.HADOOP_ADVANCED_PROPERTIES.getName().equals(param.getName()) || EParameterName.SPARK_ADVANCED_PROPERTIES.getName().equals(param.getName())) {
List<Map> list = (ArrayList) param.getValue();
for (Map map : list) {
if (map.get("BUILDIN") != null && map.get("BUILDIN").equals("TRUE")) {
if (objectValue instanceof List) {
((List) objectValue).add(map);
}
}
}
process.setPropertyValue(param.getName(), objectValue);
} else {
process.setPropertyValue(param.getName(), objectValue);
}
param.setRepositoryValueUsed(true);
param.setReadOnly(true);
repository = true;
}
}
}
}
}
}
}
}
IElementParameter property = process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
Map<String, IElementParameter> childParameters = null;
if (property != null) {
childParameters = property.getChildParameters();
}
if (!repository) {
if (childParameters != null) {
IElementParameter elementParameter = childParameters.get(EParameterName.PROPERTY_TYPE.getName());
elementParameter.setValue(EmfComponent.BUILTIN);
}
// built-in
IElementParameter dbTypeParam = null;
IElementParameter impliciteDbType = null;
for (IElementParameter param : process.getElementParameters()) {
if (param.getCategory() != category) {
continue;
}
String repositoryValue = param.getRepositoryValue();
if (param.isShow(process.getElementParameters()) && (repositoryValue != null)) {
// for mysql db verion
if (EParameterName.DB_TYPE.getName().equals(param.getName()) && "TYPE".equals(repositoryValue)) {
dbTypeParam = param;
}
if ("DB_TYPE_IMPLICIT_CONTEXT".equals(param.getName()) && "TYPE".equals(repositoryValue)) {
impliciteDbType = param;
}
if (EParameterName.DB_VERSION.getName().equals(repositoryValue) && dbTypeParam != null && dbTypeParam.getValue() != null) {
final int indexOfItem = dbTypeParam.getIndexOfItemFromList(dbTypeParam.getValue().toString());
String dbType = dbTypeParam.getListItemsDisplayCodeName()[indexOfItem];
setDBVersionForMysql(param, dbType);
} else if (EParameterName.DB_VERSION.getName().equals(repositoryValue) && impliciteDbType != null && impliciteDbType.getValue() != null) {
final int indexOfItem = impliciteDbType.getIndexOfItemFromList(impliciteDbType.getValue().toString());
String dbType = impliciteDbType.getListItemsDisplayCodeName()[indexOfItem];
setDBVersionForMysql(param, dbType);
}
param.setRepositoryValueUsed(false);
param.setReadOnly(false);
}
}
} else {
if (childParameters != null) {
IElementParameter elementParameter = childParameters.get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId((String) elementParameter.getValue());
ConnectionContextHelper.addContextForProcessParameter(process, connItem, category, false);
}
}
}
}
// else { // for extension
}
}
use of org.talend.core.model.process.EComponentCategory in project tdi-studio-se by Talend.
the class ComponentSettingsView method getCategories.
/**
* yzhang Comment method "getCategories".
*
* @param elem
* @return
*/
private EComponentCategory[] getCategories(Element elem) {
if (elem instanceof Connection) {
EComponentCategory[] categories = EElementType.CONNECTION.getCategories();
if (PluginChecker.isTeamEdition()) {
Object propertyValue = elem.getPropertyValue(Connection.LINESTYLE_PROP);
if (propertyValue instanceof EConnectionType && ((EConnectionType) propertyValue).hasConnectionCategory(IConnectionCategory.FLOW)) {
// if (((Connection) elem).checkTraceShowEnable()) {
final List<EComponentCategory> list = new ArrayList<EComponentCategory>(Arrays.asList(categories));
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
// mrjob and stormjob not add breakpoint
if (!isStormProcess && !isMRProcess) {
list.add(EComponentCategory.BREAKPOINT);
}
if (elem.getElementParameter(EParameterName.DEPARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.PARTITIONER.getName()) != null || elem.getElementParameter(EParameterName.REPARTITIONER.getName()) != null) {
list.add(EComponentCategory.PARALLELIZATION);
}
// if it mr group line then add errorRecovery
if (isMRProcess && isMrGroupLine(elem)) {
list.add(EComponentCategory.RESUMING);
}
return list.toArray(new EComponentCategory[0]);
// }
} else if (propertyValue.equals(EConnectionType.ON_COMPONENT_OK) || propertyValue.equals(EConnectionType.ON_COMPONENT_ERROR) || propertyValue.equals(EConnectionType.RUN_IF) || propertyValue.equals(EConnectionType.ON_SUBJOB_OK) || propertyValue.equals(EConnectionType.ON_SUBJOB_ERROR) || propertyValue.equals(EConnectionType.ROUTE_WHEN) || propertyValue.equals(EConnectionType.ROUTE_CATCH) || propertyValue.equals(EConnectionType.STARTS)) {
boolean isMRProcess = false;
IProcess process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process2.getComponentsType())) {
isMRProcess = true;
}
}
boolean isStormProcess = false;
process = ((Connection) elem).getSource().getProcess();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
if (ComponentCategory.CATEGORY_4_STORM.getName().equals(process2.getComponentsType())) {
isStormProcess = true;
}
}
int length = categories.length;
EComponentCategory[] newCategories;
boolean isNormalJobNeedRecovery = (!isMRProcess && !isStormProcess && !isAvoidRecoveryByConditions(elem));
boolean isMrStormJobNeedRecovery = isMRProcess || isStormProcess;
if (isNeedRecoveryCategory(propertyValue, isNormalJobNeedRecovery, isMrStormJobNeedRecovery)) {
newCategories = new EComponentCategory[length + 1];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
EComponentCategory resuming = EComponentCategory.RESUMING;
newCategories[length] = resuming;
} else {
newCategories = new EComponentCategory[length];
for (int i = 0; i < length; i++) {
newCategories[i] = categories[i];
}
}
return newCategories;
}
}
return categories;
} else if (elem instanceof Node) {
// if (isAdvancedType(elem)) {
if (((Node) elem).isELTComponent()) {
if (//$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Output") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Input") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("Map") && //$NON-NLS-1$
!((Node) elem).getComponent().getName().endsWith("TableList") && !((Node) elem).getComponent().getName().endsWith("ColumnList")) {
//$NON-NLS-1$
return EElementType.ELT_NODE.getCategories();
}
}
EComponentCategory[] categories = EElementType.ADVANCED_NODE.getCategories();
// add for bug TDI-8476
if (((Node) elem).getComponent() != null) {
String paletteType = ((Node) elem).getComponent().getPaletteType();
if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(paletteType)) {
categories = EElementType.NODE.getCategories();
}
}
if (PluginChecker.isValidationrulesPluginLoaded() && isSupportValidationRuleNode((Node) elem)) {
// show
EComponentCategory[] newCategories = new EComponentCategory[categories.length + 1];
System.arraycopy(categories, 0, newCategories, 0, categories.length);
newCategories[categories.length] = EComponentCategory.VALIDATION_RULES;
return newCategories;
}
return categories;
} else if (elem instanceof Note) {
return EElementType.NOTE.getCategories();
} else if (elem instanceof SubjobContainer) {
return EElementType.SUBJOB.getCategories();
} else if (elem instanceof ConnectionLabel) {
return getCategories(((ConnectionLabel) elem).getConnection());
}
return null;
}
Aggregations