Search in sources :

Example 6 with TalendItem

use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createRepositoryNode.

private RepositoryNode createRepositoryNode(BusinessAssignment businessAssignment) {
    IRepositoryViewObject lastVersion;
    try {
        TalendItem item = businessAssignment.getTalendItem();
        lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
        if (lastVersion != null) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(lastVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(lastVersion, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(lastVersion), ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            return repositoryNode;
        } else if (item instanceof SQLPattern) {
            IRepositoryViewObject object = getObjectFromSystem(item, ERepositoryObjectType.SQLPATTERNS);
            if (object != null) {
                RepositoryNode repositoryNode = new RepositoryNode(object, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(object), ENodeType.REPOSITORY_ELEMENT);
                repositoryNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SQLPATTERNS);
                return repositoryNode;
            }
        } else if (item instanceof Routine) {
            IRepositoryViewObject object = getObjectFromSystem(item, ERepositoryObjectType.ROUTINES);
            if (object != null) {
                RepositoryNode repositoryNode = new RepositoryNode(object, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(object), ENodeType.REPOSITORY_ELEMENT);
                repositoryNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.ROUTINES);
                return repositoryNode;
            }
        } else if (item instanceof TableMetadata) {
            MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(item.getId());
            if (table != null) {
                return RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
            }
        } else if (item instanceof Query) {
            org.talend.core.model.metadata.builder.connection.Query query = MetadataToolHelper.getQueryFromRepository(item.getId());
            if (query != null) {
                return RepositoryNodeUtilities.getQueryFromConnection(item.getId());
            }
        } else if (item instanceof SAPFunction) {
            SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(item.getId());
            if (function != null) {
                return RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
            }
        }
    } catch (PersistenceException e) {
    }
    return null;
}
Also used : TableMetadata(org.talend.designer.business.model.business.TableMetadata) SAPFunction(org.talend.designer.business.model.business.SAPFunction) SQLPattern(org.talend.designer.business.model.business.SQLPattern) Query(org.talend.designer.business.model.business.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) Routine(org.talend.designer.business.model.business.Routine) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) PersistenceException(org.talend.commons.exception.PersistenceException) TalendItem(org.talend.designer.business.model.business.TalendItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 7 with TalendItem

use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.

the class RepositoryFactoryProxyLabelProvider method getColumnImage.

@Override
public Image getColumnImage(Object object, int columnIndex) {
    Image image = super.getColumnImage(object, columnIndex);
    BusinessAssignment assignment = (BusinessAssignment) object;
    try {
        if (columnIndex == 0) {
            IRepositoryViewObject lastVersion = getLastVersion(object);
            if (lastVersion == null) {
                MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(assignment.getTalendItem().getId());
                if (table != null) {
                    return image;
                }
                Query query = MetadataToolHelper.getQueryFromRepository(assignment.getTalendItem().getId());
                if (query != null) {
                    return image;
                }
                SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(assignment.getTalendItem().getId());
                if (function != null) {
                    return image;
                }
                TalendItem item = assignment.getTalendItem();
                if (item instanceof SQLPattern) {
                    List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
                    for (IRepositoryViewObject obj : list) {
                        if (item.getLabel().equals(obj.getLabel())) {
                            return image;
                        }
                    }
                } else if (item instanceof Routine) {
                    List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
                    for (IRepositoryViewObject obj : list) {
                        if (item.getLabel().equals(obj.getLabel())) {
                            return image;
                        }
                    }
                }
                return new OverlayImage(image, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
            } else if (isDeleted(lastVersion)) {
                return new OverlayImage(image, ImageProvider.getImageDesc(ECoreImage.RECYCLE_BIN_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
            }
        }
    } catch (PersistenceException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    return image;
}
Also used : SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.core.model.metadata.builder.connection.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) Routine(org.talend.designer.business.model.business.Routine) Image(org.eclipse.swt.graphics.Image) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem)

Example 8 with TalendItem

use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.

the class RepositoryFactoryProxyLabelProvider method getColumnText.

@Override
public String getColumnText(Object object, int columnIndex) {
    String columnText = super.getColumnText(object, columnIndex);
    BusinessAssignment assignment = (BusinessAssignment) object;
    IRepositoryViewObject lastVersion = getLastVersion(object);
    try {
        if (columnIndex == 0) {
            if (lastVersion == null) {
                MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(assignment.getTalendItem().getId());
                if (table != null) {
                    if (SubItemHelper.isDeleted(table)) {
                        //$NON-NLS-1$
                        columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
                    }
                    return columnText;
                }
                Query query = MetadataToolHelper.getQueryFromRepository(assignment.getTalendItem().getId());
                if (query != null) {
                    if (SubItemHelper.isDeleted(query)) {
                        //$NON-NLS-1$
                        columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
                    }
                    return columnText;
                }
                SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(assignment.getTalendItem().getId());
                if (function != null) {
                    if (SubItemHelper.isDeleted(function)) {
                        //$NON-NLS-1$
                        columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
                    }
                    return columnText;
                }
                TalendItem item = assignment.getTalendItem();
                if (item instanceof SQLPattern) {
                    List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
                    for (IRepositoryViewObject obj : list) {
                        if (item.getLabel().equals(obj.getLabel())) {
                            return columnText;
                        }
                    }
                } else if (item instanceof Routine) {
                    List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
                    for (IRepositoryViewObject obj : list) {
                        if (item.getLabel().equals(obj.getLabel())) {
                            return columnText;
                        }
                    }
                }
                //$NON-NLS-1$
                columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.NotFound");
            } else if (isDeleted(lastVersion)) {
                //$NON-NLS-1$
                columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
            }
        }
    } catch (PersistenceException e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    if (columnIndex == 1) {
        if (lastVersion != null) {
            String label = lastVersion.getProperty().getLabel();
            if (!label.equals(columnText)) {
                ChangeTalendItemLabelCommand command = new ChangeTalendItemLabelCommand(((BusinessAssignment) object).getTalendItem(), label);
                try {
                    command.execute(null, null);
                } catch (ExecutionException e) {
                }
                return label;
            }
        }
    }
    return columnText;
}
Also used : SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.core.model.metadata.builder.connection.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) ChangeTalendItemLabelCommand(org.talend.designer.business.diagram.custom.commands.ChangeTalendItemLabelCommand) Routine(org.talend.designer.business.model.business.Routine) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 9 with TalendItem

use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.

the class ElementHelper method updateTooltipFigure.

/**
     * DOC Administrator Comment method "getTooltipFigure".
     * 
     * @param figure
     */
public void updateTooltipFigure(Figure figure, BusinessTooltipFigure tooltipFigure, EditPart editPart) {
    EObject element = ((View) editPart.getModel()).getElement();
    if (element instanceof BusinessItem) {
        List assignements = ((BusinessItem) element).getAssignments();
        BusinessItemProviderAdapterFactory adapterFactory = new BusinessItemProviderAdapterFactory();
        BusinessAssignmentItemProvider provider = (BusinessAssignmentItemProvider) adapterFactory.createBusinessAssignmentAdapter();
        Image img = null;
        Label label = null;
        List<Label> labels = new ArrayList();
        try {
            for (Object assignment : assignements) {
                if (assignment instanceof BusinessAssignment) {
                    TalendItem talendItem = ((BusinessAssignment) assignment).getTalendItem();
                    if (talendItem != null) {
                        IRepositoryViewObject obj = CorePlugin.getDefault().getProxyRepositoryFactory().getLastVersion(talendItem.getId());
                        if (obj != null) {
                            ERepositoryObjectType type = obj.getRepositoryObjectType();
                            Item item = obj.getProperty().getItem();
                            if (item instanceof JobletProcessItem) {
                                JobletProcessItem jobletItem = (JobletProcessItem) item;
                                Image jobletCustomIcon = RepositoryLabelProvider.getJobletCustomIcon(jobletItem.getProperty());
                                if (jobletCustomIcon != null) {
                                    img = ImageUtils.scale(jobletCustomIcon, ICON_SIZE.ICON_16);
                                }
                            } else {
                                img = CoreImageProvider.getImage(type);
                            }
                            //$NON-NLS-1$ //$NON-NLS-2$
                            label = new Label(obj.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", img);
                            labels.add(label);
                        } else {
                            MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(talendItem.getId());
                            Query query = MetadataToolHelper.getQueryFromRepository(talendItem.getId());
                            SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(talendItem.getId());
                            if (table != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_TABLE_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else if (query != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_QUERY_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else if (talendItem instanceof SQLPattern) {
                                List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
                                for (IRepositoryViewObject object : list) {
                                    if (talendItem.getLabel().equals(object.getLabel())) {
                                        img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SQLPATTERN_ICON.getPath()).createImage();
                                        label = new Label(//$NON-NLS-1$
                                        talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
                                        img);
                                        labels.add(label);
                                    }
                                }
                            } else if (talendItem instanceof Routine) {
                                List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
                                for (IRepositoryViewObject object : list) {
                                    if (talendItem.getLabel().equals(object.getLabel())) {
                                        img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.ROUTINE_ICON.getPath()).createImage();
                                        label = new Label(//$NON-NLS-1$
                                        talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
                                        img);
                                        labels.add(label);
                                    }
                                }
                            } else if (function != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SAPCONNECTION_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else {
                                img = (Image) provider.getImage(assignment);
                                img = new OverlayImage(img, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
                                String text = provider.getText(assignment) + " (" + provider.getColumnText(assignment, 0) + //$NON-NLS-1$ //$NON-NLS-2$
                                ")";
                                label = new Label(text, img);
                                labels.add(label);
                            }
                        }
                    }
                }
            }
            if (tooltipFigure == null) {
                tooltipFigure = new BusinessTooltipFigure();
            }
            if (labels.size() == 0) {
                figure.setToolTip(null);
            } else {
                tooltipFigure.buildFigures(labels);
                figure.setToolTip(tooltipFigure);
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.core.model.metadata.builder.connection.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) Label(org.eclipse.draw2d.Label) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) BusinessItem(org.talend.designer.business.model.business.BusinessItem) Item(org.talend.core.model.properties.Item) TalendItem(org.talend.designer.business.model.business.TalendItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) BusinessAssignmentItemProvider(org.talend.designer.business.model.business.provider.BusinessAssignmentItemProvider) EObject(org.eclipse.emf.ecore.EObject) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessTooltipFigure(org.talend.designer.business.diagram.custom.figures.BusinessTooltipFigure) Routine(org.talend.designer.business.model.business.Routine) View(org.eclipse.gmf.runtime.notation.View) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 10 with TalendItem

use of org.talend.designer.business.model.business.TalendItem in project tdi-studio-se by Talend.

the class RepositoryHelper method createTalendItem.

public TalendItem createTalendItem(Repository repository, Object object) {
    TalendItem result = null;
    if (object instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) object;
        if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            EClass class1 = getEClass(nodeType);
            if (class1 != null) {
                result = (TalendItem) BusinessFactory.eINSTANCE.create(class1);
                result.setRepository(repository);
                if (ERepositoryObjectType.METADATA_CON_TABLE.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((MetadataTableRepositoryObject) repositoryObject).getProperty();
                    Item item = property.getItem();
                    if (item instanceof SAPConnectionItem) {
                        if (repositoryNode.getParent() != null) {
                            result.setId(property.getId() + " - " + repositoryNode.getParent().getProperties(EProperties.LABEL) + " - " + repositoryObject.getLabel());
                        }
                    } else {
                        //$NON-NLS-1$
                        result.setId(property.getId() + " - " + repositoryObject.getLabel());
                    }
                } else if (ERepositoryObjectType.METADATA_CON_QUERY.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((QueryRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else if (ERepositoryObjectType.METADATA_SAP_FUNCTION.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((SAPFunctionRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else {
                    result.setId(repositoryObject.getId());
                }
                result.setLabel(repositoryObject.getLabel());
            }
        }
    }
    return result;
}
Also used : Item(org.talend.core.model.properties.Item) TalendItem(org.talend.designer.business.model.business.TalendItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) EClass(org.eclipse.emf.ecore.EClass) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendItem(org.talend.designer.business.model.business.TalendItem) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Aggregations

TalendItem (org.talend.designer.business.model.business.TalendItem)10 BusinessAssignment (org.talend.designer.business.model.business.BusinessAssignment)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 List (java.util.List)6 Routine (org.talend.designer.business.model.business.Routine)6 SQLPattern (org.talend.designer.business.model.business.SQLPattern)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)5 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 ArrayList (java.util.ArrayList)4 BusinessItem (org.talend.designer.business.model.business.BusinessItem)4 EObject (org.eclipse.emf.ecore.EObject)3 View (org.eclipse.gmf.runtime.notation.View)3 Query (org.talend.core.model.metadata.builder.connection.Query)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 Query (org.talend.designer.business.model.business.Query)3 TableMetadata (org.talend.designer.business.model.business.TableMetadata)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Image (org.eclipse.swt.graphics.Image)2