use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.
the class ExportServiceAction method addRequiredFeatures.
private void addRequiredFeatures(FeaturesModel features) {
// add correlation feature
ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
String useRegistry = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_SERVICE_REGISTRY);
if (!"true".equals(useRegistry)) {
String useCorrelation = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION);
if ("true".equals(useCorrelation)) {
features.addFeature(new FeatureModel(FeaturesModel.CORRELATION_FEATURE_NAME));
}
}
// add talend-data-mapper feature
for (IRepositoryViewObject node : nodes) {
ProcessItem processItem = (ProcessItem) node.getProperty().getItem();
if (null != EmfModelUtils.getComponentByName(processItem, THMAP_COMPONENT_NAME)) {
features.addFeature(new FeatureModel(FeaturesModel.TALEND_DATA_MAPPER_FEATURE_NAME));
break;
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.
the class ExportServiceAction method init.
private void init(String targetPath) throws InvocationTargetException {
serviceName = serviceItem.getProperty().getLabel();
serviceVersion = serviceItem.getProperty().getVersion();
serviceWsdl = WSDLUtils.getWsdlFile(serviceItem);
ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
additionalInfo = serviceConnection.getAdditionalInfo().map();
EList<ServicePort> listPort = serviceConnection.getServicePort();
List<IRepositoryViewObject> jobs;
try {
jobs = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
for (ServicePort port : listPort) {
List<ServiceOperation> listOperation = port.getServiceOperation();
Map<String, String> operations = new HashMap<String, String>(listOperation.size());
for (ServiceOperation operation : listOperation) {
String jobId = operation.getReferenceJobId();
if (jobId != null && !jobId.equals("")) {
String operationName = operation.getName();
IRepositoryViewObject jobNode = null;
for (IRepositoryViewObject job : jobs) {
if (job.getId().equals(jobId)) {
jobNode = job;
break;
}
}
if (jobNode == null) {
continue;
}
String jobName = jobNode.getLabel();
operations.put(operationName, jobName);
nodes.add(jobNode);
contextValues.putAll(JobContextUtils.getContextsMap((ProcessItem) jobNode.getProperty().getItem()));
}
}
ports.put(port, operations);
}
if (this.serviceManager == null) {
this.serviceManager = new ServiceExportManager(exportChoiceMap);
}
serviceManager.setDestinationPath(targetPath);
tempFolder = getTmpFolderPath();
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutinesFromRepository.
private Collection<IRepositoryViewObject> collectRoutinesFromRepository(Set<String> allRoutinesNames, ERepositoryObjectType type) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
try {
List<IRepositoryViewObject> availableRoutines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), type);
for (IRepositoryViewObject object : availableRoutines) {
if (allRoutinesNames.contains(object.getLabel())) {
allRoutinesNames.remove(object.getLabel());
toReturn.add(object);
}
}
if (allRoutinesNames.isEmpty()) {
return toReturn;
}
for (org.talend.core.model.general.Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
for (IRepositoryViewObject object : factory.getAll(project, type)) {
if (allRoutinesNames.contains(object.getLabel())) {
allRoutinesNames.remove(object.getLabel());
toReturn.add(object);
}
}
if (allRoutinesNames.isEmpty()) {
return toReturn;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
}
return toReturn;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class SQLBuilderDialog method deleteNoUseTable.
private void deleteNoUseTable() {
// add for bug TDI-17097
connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem(SQLBuilderRepositoryNodeManager.getRoot(nodeInEditor)).getConnection();
if (SQLBuilderRepositoryNodeManager.tList instanceof List) {
if (SQLBuilderRepositoryNodeManager.tList.size() == 0) {
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
} else {
SQLBuilderRepositoryNodeManager.tList = new ArrayList<MetadataTable>();
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
if (SQLBuilderRepositoryNodeManager.tList == null || SQLBuilderRepositoryNodeManager.tList.size() == 0) {
return;
}
// changed for bug TDI-19892
if (node == null) {
SQLBuilderRepositoryNodeManager.tList = null;
return;
}
IRepositoryViewObject repositoryObject = node.getObject();
Item item = repositoryObject.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
manager.deleteNouseTables(((DatabaseConnectionItem) item).getConnection());
}
}
Aggregations