Search in sources :

Example 6 with ITDQPatternService

use of org.talend.core.ITDQPatternService in project tdi-studio-se by Talend.

the class ControllerRepositoryValueHander method fastRepositoryUpdateProperty.

private void fastRepositoryUpdateProperty(IElementParameter param) {
    if (param != null && param.getValue() != null) {
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        String linkedRepository = (String) param.getValue();
        // value stored is the id, so we can get this item directly
        Item item;
        String displayName = "";
        try {
            IRepositoryViewObject object = factory.getLastVersion(linkedRepository.split(" - ")[0]);
            if (object == null) {
                return;
            }
            item = object.getProperty().getItem();
            // Assert.isTrue(item instanceof ConnectionItem);
            IESBService service = null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
            }
            if (service != null && ERepositoryObjectType.getItemType(item) == service.getServicesType()) {
                lastItemUsed = (ConnectionItem) item;
                displayName = "Service:" + service.getServiceLabel(item, linkedRepository);
            } else if (item instanceof ConnectionItem) {
                lastItemUsed = (ConnectionItem) item;
                displayName = //$NON-NLS-1$
                RepositoryObjectHelper.getRepositoryAliasName(lastItemUsed) + ":" + lastItemUsed.getProperty().getLabel();
            }
            if (item instanceof FileItem) {
                // hywang add for 6484
                lastFileItemUsed = (FileItem) item;
                if (lastFileItemUsed instanceof RulesItem) {
                    displayName = //$NON-NLS-1$
                    "Rules:" + lastFileItemUsed.getProperty().getLabel();
                }
            }
            if (item instanceof LinkRulesItem) {
                lastLinkItem = (LinkRulesItem) item;
                displayName = //$NON-NLS-1$
                "Rules:" + lastLinkItem.getProperty().getLabel();
            }
            if (StringUtils.isEmpty(displayName)) {
                ITDQPatternService tdqService = null;
                try {
                    tdqService = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
                    if (tdqService != null) {
                        displayName = tdqService.getPatternDisplayName(item);
                    }
                } catch (RuntimeException e) {
                // nothing to do
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
        param.setListItemsDisplayName(new String[] { displayName });
        param.setListItemsValue(new String[] { (String) param.getValue() });
    }
}
Also used : LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) Item(org.talend.core.model.properties.Item) FileItem(org.talend.core.model.properties.FileItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) FileItem(org.talend.core.model.properties.FileItem) IESBService(org.talend.core.IESBService) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ITDQPatternService(org.talend.core.ITDQPatternService) RulesItem(org.talend.core.model.properties.RulesItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 7 with ITDQPatternService

use of org.talend.core.ITDQPatternService in project tdi-studio-se by Talend.

the class PropertyTypeController method processPattern.

// Added TDQ-13192 20170222
private Command processPattern(IElement elem) {
    CompoundCommand compoundCommand = new CompoundCommand();
    ITDQPatternService service = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
        service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
    }
    if (service != null && elem instanceof Node) {
        Node node = (Node) elem;
        //$NON-NLS-1$
        IElementParameter typeParam = node.getElementParameter("TYPE");
        boolean hadSelected = service.selectPattern(typeParam, elem);
        if (hadSelected) {
            // create the command
            //$NON-NLS-1$
            final String showId = (String) node.getElementParameter("PATTERN_ID").getValue();
            compoundCommand = new CompoundCommand();
            Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
            compoundCommand.add(command);
            IElementParameter elementParameter = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            String[] displayName = new String[1];
            //$NON-NLS-1$
            displayName[0] = (String) node.getElementParameter("PATTERN_NAME").getValue();
            elementParameter.setListItemsDisplayName(displayName);
            elementParameter.setListItemsValue(new String[] { showId });
        }
    }
    return compoundCommand;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQPatternService(org.talend.core.ITDQPatternService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

ITDQPatternService (org.talend.core.ITDQPatternService)7 IElementParameter (org.talend.core.model.process.IElementParameter)6 INode (org.talend.core.model.process.INode)5 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 PersistenceException (org.talend.commons.exception.PersistenceException)3 IESBService (org.talend.core.IESBService)3 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)3 Item (org.talend.core.model.properties.Item)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)2 FileItem (org.talend.core.model.properties.FileItem)2