Search in sources :

Example 1 with ChangeTalendItemLabelCommand

use of org.talend.designer.business.diagram.custom.commands.ChangeTalendItemLabelCommand 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)

Aggregations

List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 Query (org.talend.core.model.metadata.builder.connection.Query)1 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ChangeTalendItemLabelCommand (org.talend.designer.business.diagram.custom.commands.ChangeTalendItemLabelCommand)1 BusinessAssignment (org.talend.designer.business.model.business.BusinessAssignment)1 Routine (org.talend.designer.business.model.business.Routine)1 SQLPattern (org.talend.designer.business.model.business.SQLPattern)1 TalendItem (org.talend.designer.business.model.business.TalendItem)1