Search in sources :

Example 1 with HDFSConnectionItem

use of org.talend.repository.model.hdfs.HDFSConnectionItem in project tbd-studio-se by Talend.

the class HDFSConnectionTestUtils method createHDFSItem.

public static HDFSConnectionItem createHDFSItem(String id, String name) {
    HDFSConnection connection = HDFSFactory.eINSTANCE.createHDFSConnection();
    // $NON-NLS-1$
    connection.setRowSeparator("\\n");
    // $NON-NLS-1$
    connection.setFieldSeparator(";");
    // $NON-NLS-1$
    connection.setHeaderValue("2");
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
    // $NON-NLS-1$
    connectionProperty.setStatusCode("");
    connectionProperty.setId(id);
    connectionProperty.setLabel(name);
    HDFSConnectionItem connectionItem = HDFSFactory.eINSTANCE.createHDFSConnectionItem();
    connectionItem.setProperty(connectionProperty);
    connectionItem.setConnection(connection);
    return connectionItem;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) Property(org.talend.core.model.properties.Property) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Example 2 with HDFSConnectionItem

use of org.talend.repository.model.hdfs.HDFSConnectionItem in project tbd-studio-se by Talend.

the class HDFSDragAndDropHandler method filterNeededComponents.

@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (!(item instanceof HDFSConnectionItem)) {
        return neededComponents;
    }
    IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
    Collection<IComponent> components = service.getComponentsFactory().readComponents();
    for (IComponent component : components) {
        if (isValid(item, type, seletetedNode, component, HDFS) && !neededComponents.contains(component)) {
            neededComponents.add(component);
        }
    }
    return neededComponents;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Example 3 with HDFSConnectionItem

use of org.talend.repository.model.hdfs.HDFSConnectionItem in project tbd-studio-se by Talend.

the class HDFSRepositoryContentHandler method create.

@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
    Resource itemResource = null;
    if (item.eClass() == HDFSPackage.Literals.HDFS_CONNECTION_ITEM) {
        ERepositoryObjectType type = HDFSRepositoryNodeType.HDFS;
        itemResource = create(project, (HDFSConnectionItem) item, path, type);
    }
    return itemResource;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Example 4 with HDFSConnectionItem

use of org.talend.repository.model.hdfs.HDFSConnectionItem in project tbd-studio-se by Talend.

the class HDFSDragAndDropHandler method getCorrespondingComponentName.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
    RepositoryComponentSetting setting = null;
    if (item instanceof HDFSConnectionItem) {
        setting = new RepositoryComponentSetting();
        setting.setName(HDFS);
        setting.setRepositoryType(HDFS);
        setting.setWithSchema(true);
        setting.setInputComponent(INPUT);
        setting.setOutputComponent(OUTPUT);
        List<Class<Item>> list = new ArrayList<Class<Item>>();
        Class clazz = null;
        try {
            clazz = Class.forName(HDFSConnectionItem.class.getName());
        } catch (ClassNotFoundException e) {
            ExceptionHandler.process(e);
        }
        list.add(clazz);
        setting.setClasses(list.toArray(new Class[0]));
    }
    return setting;
}
Also used : Item(org.talend.core.model.properties.Item) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem) RepositoryComponentSetting(org.talend.core.repository.RepositoryComponentSetting) ArrayList(java.util.ArrayList) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Example 5 with HDFSConnectionItem

use of org.talend.repository.model.hdfs.HDFSConnectionItem in project tbd-studio-se by Talend.

the class CreateHDFSSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    HDFSConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        HDFSConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (HDFSConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HDFSConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == HDFSRepositoryNodeType.HDFS) {
            item = (HDFSConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HDFSConnection) item.getConnection();
            creation = true;
        } else {
            return;
        }
        boolean isOK = true;
        if (creation) {
            isOK = checkHDFSConnection((HDFSConnection) item.getConnection());
        }
        if (isOK) {
            openHDFSSchemaWizard(item, metadataTable, false, creation);
        }
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Aggregations

HDFSConnectionItem (org.talend.repository.model.hdfs.HDFSConnectionItem)5 ArrayList (java.util.ArrayList)2 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 HDFSConnection (org.talend.repository.model.hdfs.HDFSConnection)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 IComponent (org.talend.core.model.components.IComponent)1 IComponentsService (org.talend.core.model.components.IComponentsService)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 RepositoryComponentSetting (org.talend.core.repository.RepositoryComponentSetting)1