Search in sources :

Example 1 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryViewFilterDialog method updateForEventManager.

private void updateForEventManager(Set<String> values) {
    ERepositoryObjectType[] types = new ERepositoryObjectType[] { IServerObjectRepositoryType.TYPE_TRANSFORMERV2, IServerObjectRepositoryType.TYPE_ROUTINGRULE };
    for (ERepositoryObjectType type : types) {
        IRepositoryNodeConfiguration conf = RepositoryNodeConfigurationManager.getConfiguration(type);
        IRepositoryViewObject viewObject = RepositoryResourceUtil.getCategoryViewObject(conf);
        if (viewObject != null) {
            ContainerItem item = (ContainerItem) viewObject.getProperty().getItem();
            values.add(item.getLabel());
        }
    }
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryViewFilterDialog method getLabel.

private String getLabel(Object element) {
    if (element instanceof IRepositoryViewObject) {
        Item item = ((IRepositoryViewObject) element).getProperty().getItem();
        IRepositoryNodeConfiguration conf = RepositoryNodeConfigurationManager.getConfiguration(item);
        if (conf != null)
            return conf.getLabelProvider().getText(element);
    }
    // $NON-NLS-1$
    return "";
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration)

Example 3 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryNodeConfigurationManager method initTemplateDefine.

private static void initTemplateDefine() {
    if (!inited) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        // 
        IExtensionPoint extensionPoint = registry.getExtensionPoint(RepositoryPlugin.PLUGIN_ID, EXTENSION_POINT_TEMPLATE);
        if (extensionPoint != null && extensionPoint.isValid()) {
            IExtension[] extensions = extensionPoint.getExtensions();
            for (IExtension s : extensions) {
                IConfigurationElement[] elements = s.getConfigurationElements();
                for (IConfigurationElement element : elements) {
                    if (element.getAttribute(PROP_CLASS) != null) {
                        try {
                            IRepositoryNodeConfiguration configuration = (IRepositoryNodeConfiguration) element.createExecutableExtension(PROP_CLASS);
                            configurations.add(configuration);
                        } catch (CoreException e) {
                            log.error(e.getMessage(), e);
                        }
                    }
                }
            }
        // Bean2EObjUtil.getInstance().dumpMap();
        }
        inited = true;
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 4 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryNodeConfigurationManager method getConfiguration.

public static IRepositoryNodeConfiguration getConfiguration(Item item) {
    EClass eClass = item.eClass();
    IRepositoryNodeConfiguration configuration = itemConfMap.get(eClass);
    if (configuration != null) {
        return configuration;
    }
    for (IRepositoryNodeConfiguration conf : getConfigurations()) {
        IRepositoryNodeResourceProvider resourceProvider = conf.getResourceProvider();
        if (resourceProvider != null) {
            if (resourceProvider.canHandleItem(item)) {
                if (!(item instanceof ContainerItem)) {
                    itemConfMap.put(eClass, conf);
                }
                return conf;
            }
        }
    }
    if (recycleBinNodeConfiguration.getResourceProvider().canHandleItem(item)) {
        return recycleBinNodeConfiguration;
    }
    return null;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration)

Example 5 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method createItem.

public static boolean createItem(Item item, String propLabel, String version, boolean pushCommandStack, boolean triggerEvent) {
    String name = propLabel;
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    RepositoryContext context = factory.getRepositoryContext();
    Property prop = PropertiesFactory.eINSTANCE.createProperty();
    item.setProperty(prop);
    try {
        String nextId = factory.getNextId();
        Property property = item.getProperty();
        property.setId(nextId);
        property.setVersion(version);
        property.setAuthor(context.getUser());
        property.setLabel(propLabel);
        // 
        factory.create(item, new Path(item.getState().getPath()));
        item = assertItem(item);
        // 
        IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
        if (configuration != null) {
            IRepositoryNodeResourceProvider resourceProvider = configuration.getResourceProvider();
            if (resourceProvider.needSaveReferenceFile()) {
                resourceProvider.handleReferenceFile(item);
            }
            factory.save(item, !triggerEvent);
            try {
                factory.unlock(item);
            } catch (LoginException e) {
                log.error(e.getMessage(), e);
            }
        }
        if (pushCommandStack) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, nextId, name);
        }
        return true;
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    }
    return false;
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) RepositoryContext(org.talend.core.context.RepositoryContext) IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) LoginException(org.talend.commons.exception.LoginException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)9 Item (org.talend.core.model.properties.Item)8 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)8 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 RepositoryContext (org.talend.core.context.RepositoryContext)5 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 Property (org.talend.core.model.properties.Property)4 User (org.talend.core.model.properties.User)4 ResourceBundle (java.util.ResourceBundle)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3 Before (org.junit.Before)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 LoginException (org.talend.commons.exception.LoginException)3 Project (org.talend.core.model.general.Project)3 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)3